Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Importing/running cached functions in proxy.ts | GoodFirstPicks

Importing/running cached functions in proxy.ts

vercel/next.js 2 comments 3d ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeNext.jsTypeScriptReact

Why this is a good first issue

The issue involves runtime-specific behavior with cached functions in proxy.ts.

AI Summary

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.

Issue Description

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/empty-glade-srklzq

To Reproduce

  1. Start the application in dev mode (next dev)
  2. Open the browser and navigate to the application (usually http://localhost:3000)
  3. Errors will appear in both the console and on screen

Current vs. Expected behavior

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.
Image

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?

Provide environment information

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

GitHub Labels

MiddlewareRuntimeCache Components

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!

Risk Flags

  • runtime-specific behavior
  • potential undocumented limitations
Loading labels...

Details

Points20 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno