feat(cache): detect 'use cache' module-scope deadlocks early in dev#1155
Closed
Divkix wants to merge 1 commit into
Closed
feat(cache): detect 'use cache' module-scope deadlocks early in dev#1155Divkix wants to merge 1 commit into
Divkix wants to merge 1 commit into
Conversation
commit: |
…loudflare#1126) Ports Next.js use-cache deadlock probe (vercel/next.js#93500, vercel/next.js#93538): - UseCacheTimeoutError / UseCacheDeadlockError with digest codes - Dev-only timeout around 'use cache' fills (default 30s) - Probe scheduler that fires after 10s idle time in dev - Worker-thread probe pool that re-executes the function with fresh module scope - Request store snapshot forwarding so private caches resolve correctly - HMR teardown so probes don't use stale module caches - Gated on NODE_ENV === 'development', tree-shakes out of production/Workers New files: - shims/use-cache-errors.ts - server/use-cache-probe-globals.ts - server/use-cache-probe-scheduler.ts - server/use-cache-probe-pool.ts - server/use-cache-probe-worker.ts Modified: - shims/cache-runtime.ts (dev timeout + probe integration) - index.ts (install probe in configureServer) Tests: - tests/use-cache-deadlock.test.ts (10 tests, all passing)
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1126
Ports the Next.js use-cache deadlock probe (vercel/next.js#93500, vercel/next.js#93538) to vinext.
Problem
When a "use cache" function deadlocks in vinext dev due to module-scope state (e.g. a top-level joining a hanging promise from outer scope), users get an indefinite hang with no actionable error.
Solution
All new probe code is gated on and tree-shakes out of production / Workers builds.