The issue involves runtime-specific behavior with cached functions in proxy.ts.
The issue involves a cached function (`cacheLife`) that fails to run correctly within `proxy.ts`, despite being marked with `'use cache'`. The error suggests a runtime-specific limitation or bug, but it's unclear whether this is intended behavior or a bug. The problem requires investigation into how caching interacts with the proxy/middleware runtime.
https://codesandbox.io/p/devbox/empty-glade-srklzq
I expect the cached function to run in the proxy.ts. In my actual code (looks very similar), I'm doing a cheap API call, cached as "weeks", in order to load some configurations for a multi-tenant application. This basic multi-tenant configuration is hosted externally and is rarely changes, so it shouldn't be fetched for every new visitor of the application, and definitely not for every new request. However, the result is needed in order to start loading the page.
Currently, I get the following error in the terminal and as a popup when running next dev:
`cacheLife()` can only be called inside a "use cache" function.
cacheLife is in fact being called inside a "use cache" function and it works as expected if I use the function in any other place than proxy.ts. The error message implies that the issue is that the function doesn't have "use cache", but it seems to have more to do with the usage inside of proxy.ts.
Is this intended but undocumented behavior, a bug, or am I missing something?
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 25.0.0: Wed Sep 17 21:41:45 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T6000
Available memory (MB): 16384
Available CPU cores: 8
Binaries:
Node: 22.5.1
npm: 10.8.2
Yarn: 1.22.22
pnpm: N/A
Relevant Packages:
next: 16.0.0 // Latest available version is detected (16.0.0).
eslint-config-next: N/A
react: 19.2.0
react-dom: 19.2.0
typescript: 5.9.3
N
Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!