Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In dev mode, "incrementalCache missing in unstable_cache" when using unstable_cache in middleware #70085

Open
tom-sherman opened this issue Sep 13, 2024 · 1 comment
Labels
bug Issue was opened via the bug report template. Middleware Related to Next.js Middleware. Turbopack Related to Turbopack with Next.js. Webpack Related to Webpack with Next.js.

Comments

@tom-sherman
Copy link

Link to the code that reproduces this issue

https://github.com/tom-sherman/next-missing-incrementalcache-bug

To Reproduce

  1. next dev
  2. Open /

Current vs. Expected behavior

unhandledRejection: Error: Invariant: incrementalCache missing in unstable_cache ()=>Promise.resolve()
    at cachedCb (webpack-internal:///(middleware)/./node_modules/.pnpm/[email protected][email protected][email protected]_2ydu7yowbuals2jgbmseymwiiq/node_modules/next/dist/esm/server/web/spec-extension/unstable-cache.js:64:19)
    at middleware (webpack-internal:///(middleware)/./middleware.ts:12:5)
    at Object.eval [as handler] (webpack-internal:///(middleware)/./node_modules/.pnpm/[email protected][email protected][email protected]_2ydu7yowbuals2jgbmseymwiiq/node_modules/next/dist/build/webpack/loaders/next-middleware-loader.js?absolutePagePath=%2Fhome%2Ftom%2Fcode%2Fnext-missing-incrementalcache-bug%2Fmiddleware.ts&page=%2Fmiddleware&rootDir=%2Fhome%2Ftom%2Fcode%2Fnext-missing-incrementalcache-bug&matchers=&preferredRegion=&middlewareConfig=e30%3D!:26:26)
    at eval (webpack-internal:///(middleware)/./node_modules/.pnpm/[email protected][email protected][email protected]_2ydu7yowbuals2jgbmseymwiiq/node_modules/next/dist/esm/server/web/adapter.js:215:35)
    at AsyncLocalStorage.run (node:async_hooks:346:14)
    at withRequestStore (webpack-internal:///(middleware)/./node_modules/.pnpm/[email protected][email protected][email protected]_2ydu7yowbuals2jgbmseymwiiq/node_modules/next/dist/esm/server/async-storage/with-request-store.js:106:20)
    at eval (webpack-internal:///(middleware)/./node_modules/.pnpm/[email protected][email protected][email protected]_2ydu7yowbuals2jgbmseymwiiq/node_modules/next/dist/esm/server/web/adapter.js:201:118)
    at eval (webpack-internal:///(middleware)/./node_modules/.pnpm/[email protected][email protected][email protected]_2ydu7yowbuals2jgbmseymwiiq/node_modules/next/dist/esm/server/lib/trace/tracer.js:142:36)
    at NoopContextManager.with (webpack-internal:///(middleware)/./node_modules/.pnpm/[email protected][email protected][email protected]_2ydu7yowbuals2jgbmseymwiiq/node_modules/next/dist/compiled/@opentelemetry/api/index.js:2:7062)
    at ContextAPI.with (webpack-internal:///(middleware)/./node_modules/.pnpm/[email protected][email protected][email protected]_2ydu7yowbuals2jgbmseymwiiq/node_modules/next/dist/compiled/@opentelemetry/api/index.js:2:518)

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Fri Mar 29 23:14:13 UTC 2024
  Available memory (MB): 7841
  Available CPU cores: 16
Binaries:
  Node: 20.12.1
  npm: 10.5.0
  Yarn: 1.22.22
  pnpm: 9.9.0
Relevant Packages:
  next: 15.0.0-canary.150 // There is a newer canary version (15.0.0-canary.154) available, please upgrade! 
  eslint-config-next: N/A
  react: 19.0.0-rc-7771d3a7-20240827
  react-dom: 19.0.0-rc-7771d3a7-20240827
  typescript: 5.3.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Middleware, Turbopack, Webpack

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

This is reproducible with and without --turbo.

Related to #51397 and #60336

@tom-sherman tom-sherman added the bug Issue was opened via the bug report template. label Sep 13, 2024
@github-actions github-actions bot added Middleware Related to Next.js Middleware. Turbopack Related to Turbopack with Next.js. Webpack Related to Webpack with Next.js. labels Sep 13, 2024
@nhducit
Copy link
Contributor

nhducit commented Sep 16, 2024

Fetch is not patched in the middleware. I guess unstable_cache is also not supported in the middleware, but this is not mentioned in the documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Middleware Related to Next.js Middleware. Turbopack Related to Turbopack with Next.js. Webpack Related to Webpack with Next.js.
Projects
None yet
Development

No branches or pull requests

2 participants