You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On initial load, the page will correctly display the contents of the Map
Refresh the page
The page will show an error cachedMap.entries is not a function
Current vs. Expected behavior
Following the steps from the previous section, I expected to still see the contents of the map even after refreshing / loading a cached version of the Map.
It seems to me that the Map is being loaded as an instance of Object. That's why it doesn't have an entries method defined.
If I inspect the cache contents at ./.next/cache/fetch-cache I see
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP PREEMPT_DYNAMIC Sun Aug 6 20:05:33 UTC 2023
Available memory (MB): 4102
Available CPU cores: 2
Binaries:
Node: 20.9.0
npm: 9.8.1
Yarn: 1.22.19
pnpm: 8.10.2
Relevant Packages:
next: 14.2.0-canary.9 // There is a newer canary version (14.3.0-canary.13) available, please upgrade!
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0
typescript: 5.1.3
Next.js Config:
output: N/A
⚠ There is a newer canary version (14.3.0-canary.13) available, please upgrade!
Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
Read more - https://nextjs.org/docs/messages/opening-an-issue
Which area(s) are affected? (Select all that apply)
Runtime
Which stage(s) are affected? (Select all that apply)
next dev (local), Vercel (Deployed)
Additional context
I tried to install latest canary in the sandbox, but the install command was erroring in CodeSandbox.
I've observed this exact issue outside of CodeSandbox environments, I'm certain the issue is not environment related (I've observed in Vercel deployments too).
The text was updated successfully, but these errors were encountered:
taylorjohnwood
changed the title
unstable_cache loads Object instance instead of Map instance from cache. unstable_cache loads Object instance instead of Map instance from unstable_cache.
Apr 20, 2024
taylorjohnwood
changed the title
unstable_cache loads Object instance instead of Map instance from unstable_cache. unstable_cache loads Object instance instead of Map instance from cache.
Apr 20, 2024
I could draft a doc's update as my first contribution to Next, but I'm not sure how people feeling about documenting an unstable API (unstable_cache).
I would think there should be some warning/runtime error/lint issue when a user attempts to cache a non-serializable instance. Perhaps this could be added as well?
Link to the code that reproduces this issue
https://codesandbox.io/p/sandbox/unstable-cache-map-bug-mq2xxm
To Reproduce
next dev
)Map
cachedMap.entries is not a function
Current vs. Expected behavior
Following the steps from the previous section, I expected to still see the contents of the map even after refreshing / loading a cached version of the
Map
.It seems to me that the
Map
is being loaded as an instance ofObject
. That's why it doesn't have anentries
method defined.If I inspect the cache contents at
./.next/cache/fetch-cache
I seeProvide environment information
Which area(s) are affected? (Select all that apply)
Runtime
Which stage(s) are affected? (Select all that apply)
next dev (local), Vercel (Deployed)
Additional context
I tried to install latest canary in the sandbox, but the install command was erroring in CodeSandbox.
I've observed this exact issue outside of CodeSandbox environments, I'm certain the issue is not environment related (I've observed in Vercel deployments too).
The text was updated successfully, but these errors were encountered: