Skip to content

fix(preview-server): localStoraget.getItem is not a function error#2644

Merged
gabrielmfern merged 2 commits intocanaryfrom
fix/local-storage-issues-with-node-25
Nov 5, 2025
Merged

fix(preview-server): localStoraget.getItem is not a function error#2644
gabrielmfern merged 2 commits intocanaryfrom
fix/local-storage-issues-with-node-25

Conversation

@gabrielmfern
Copy link
Member

@gabrielmfern gabrielmfern commented Nov 4, 2025

Fixing the error

TypeError: a.g.localStorage.getItem is not a function
    at bf (turbopack:///[project]/packages/preview-server/src/components/toolbar/use-cached-state.ts:6:45)
    at bh (turbopack:///[project]/packages/preview-server/src/components/toolbar.tsx:81:5)
  4 |   let value: T | undefined;
  5 |   if ('localStorage' in global) {
> 6 |     const storedValue = global.localStorage.getItem(key);
    |                                             ^
  7 |     if (storedValue !== null && storedValue !== 'undefined') {
  8 |       try {
  9 |         value = JSON.parse(storedValue) as T; {
  digest: '3099065385'
}

Only got this when using Node.js 25, so I'm assuming it's probably related. Can confirm the issue's gone after this when running locally.


Summary by cubic

Fix preview-server crash in Node.js 25 by guarding against non-function localStorage.getItem in useCachedState. This prevents the TypeError and lets the toolbar render without failing.

Written for commit b91cafc. Summary will update automatically on new commits.

@gabrielmfern gabrielmfern requested a review from a team November 4, 2025 20:52
@gabrielmfern gabrielmfern self-assigned this Nov 4, 2025
@gabrielmfern gabrielmfern requested review from felipevolpone and removed request for a team November 4, 2025 20:52
@changeset-bot
Copy link

changeset-bot bot commented Nov 4, 2025

⚠️ No Changeset found

Latest commit: b91cafc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Nov 4, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
react-email Ready Ready Preview Comment Nov 4, 2025 8:56pm
react-email-demo Ready Ready Preview Comment Nov 4, 2025 8:56pm

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 4, 2025

Open in StackBlitz

npm i https://pkg.pr.new/resend/react-email/@react-email/preview-server@2644

commit: 0a14261

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@gabrielmfern gabrielmfern merged commit 0f0c98a into canary Nov 5, 2025
15 of 17 checks passed
@gabrielmfern gabrielmfern deleted the fix/local-storage-issues-with-node-25 branch November 5, 2025 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants