Skip to content

Conversation

@gnoff
Copy link
Contributor

@gnoff gnoff commented Oct 17, 2025

This change refactors the edge-config implementation in preparation for supporting Next.js specific builds. The key goal is to prepare the function interfaces where we intend to push the "use cache" boundaries for Next.js support so they are stringly typed. This is to help with optimizing a fast path for "use cache" that can avoid some serialization.

One concession in this refactor is we need to move from a closure for the dev-only SWR edge config fetcher. The problem with this architecture is the function created in the closure won't be accessible to the the individual methods (like get) when they are behind a "use cache" because functions are not serializable. The technique now employed is a lazy created SWR deduper that is keyed off the connection string. This implementation does not consider garbage collection when clients are collected because 1) this is dev only and dev servers don't live very long and 2) this library does not typically require creating arbitrarily many clients since connections are typically stable for the lifetime of a deployment. We could use a FinalizationRegistry but that would limit support to runtimes that provide this and require some careful conditional requiring which just adds bundling complexity.

@changeset-bot
Copy link

changeset-bot bot commented Oct 17, 2025

🦋 Changeset detected

Latest commit: d0c5005

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@vercel/edge-config Patch
vercel-storage-integration-test-suite Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Contributor

vercel bot commented Oct 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
vercel-storage-next-integration-test-suite Ready Ready Preview Oct 22, 2025 1:17pm

@socket-security
Copy link

socket-security bot commented Oct 17, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednext@​15.2.0 ⏵ 15.2.58389 +6491 +19870

View full report

@gnoff gnoff force-pushed the jstory/prep-refactor branch 4 times, most recently from f4ab323 to 4a4582d Compare October 17, 2025 21:19
@gnoff gnoff force-pushed the jstory/prep-refactor branch 3 times, most recently from cb3bcd4 to b7242b1 Compare October 17, 2025 21:29
@gnoff gnoff force-pushed the jstory/prep-refactor branch from b7242b1 to b864cf4 Compare October 17, 2025 22:14
@gnoff gnoff changed the title TBD Refactor edge-config to prepare for Next.js support Oct 17, 2025
This change refactors the edge-config implementation in preparation for supporting Next.js specific builds. The key goal is to prepare the function interfaces where we intend to push the "use cache" boundaries for Next.js support so they are stringly typed. This is to help with optimizing a fast path for "use cache" that can avoid some serialization.

One concession in this refactor is we need to move from a closure for the dev-only SWR edge config fetcher. The problem with this architecture is the function created in the closure won't be accessible to the the individual methods (like get) when they are behind a "use cache" because functions are not serializable. The technique now employed is a lazy created SWR deduper that is keyed off the connection string. This implementation does not consider garbage collection when clients are collected because 1) this is dev only and dev servers don't live very long and 2) this library does not typically require creating arbitrarily many clients since connections are typically stable for the lifetime of a deployment. We could use a FinalizationRegistry but that would limit support to runtimes that provide this and require some careful conditional requiring which just adds bundling complexity.
Copy link
Member

@luismeyer luismeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the next-legacy/.next folder checked into git on puprose?

@dferber90 dferber90 requested a review from luismeyer October 21, 2025 06:33
@dferber90 dferber90 enabled auto-merge (squash) October 22, 2025 10:26
@dferber90 dferber90 merged commit 632977b into main Oct 22, 2025
11 checks passed
@dferber90 dferber90 deleted the jstory/prep-refactor branch October 22, 2025 13:45
@dferber90 dferber90 mentioned this pull request Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants