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

@svgr/webpack integration crashes on render inside server component (undefined runtime error) #69545

Closed
mobeigi opened this issue Sep 1, 2024 · 2 comments · Fixed by #70486
Closed
Assignees
Labels
bug Issue was opened via the bug report template. locked Runtime Related to Node.js or Edge Runtime with Next.js. Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).

Comments

@mobeigi
Copy link
Contributor

mobeigi commented Sep 1, 2024

Link to the code that reproduces this issue

https://github.com/mobeigi/react-next-svgr-bug

To Reproduce

  1. Clone linked repo
  2. yarn install
  3. yarn dev
  4. Visit: http://localhost:3000/good
  5. Refresh page (multiple times).
  6. Visit: http://localhost:3000/bad
  7. Refresh page (multiple times).

The repository provided is a barebones Next 15 + React 19 + Typescript + Yarn app created with create-next-app.
It also has SVGR intregration via @svfr/webpack following instructions from here: https://react-svgr.com/docs/next/

Current vs. Expected behavior

Behaviour

It is expected that both the good and bad pages from the reproduction repo will load fine without issue and refreshes should also load fine.

The good page (with only 1 distinct SVG) loads fine without issues.
However, the bad page (with 2+ distinct SVGs) only renders fine for initial load. A reload of the page triggers a crash and produces a (unhandled Runtime Error).

Exception

Example exception from Chrome:

TypeError: Cannot read properties of undefined (reading '$$typeof')
    at getOutlinedModel (react-server-dom-webpack-client.browser.development.js:1056:1)
    at parseModelString (react-server-dom-webpack-client.browser.development.js:1249:1)
    at Object.eval (react-server-dom-webpack-client.browser.development.js:1833:1)
    at JSON.parse (<anonymous>)
    at initializeModelChunk (react-server-dom-webpack-client.browser.development.js:881:1)
    at getOutlinedModel (react-server-dom-webpack-client.browser.development.js:1046:1)
    at parseModelString (react-server-dom-webpack-client.browser.development.js:1249:1)
    at Array.eval (react-server-dom-webpack-client.browser.development.js:1833:1)
    at JSON.parse (<anonymous>)
    at initializeModelChunk (react-server-dom-webpack-client.browser.development.js:881:1)
    at getOutlinedModel (react-server-dom-webpack-client.browser.development.js:1046:1)
    at parseModelString (react-server-dom-webpack-client.browser.development.js:1249:1)
    at Array.eval (react-server-dom-webpack-client.browser.development.js:1833:1)
    at JSON.parse (<anonymous>)
    at initializeModelChunk (react-server-dom-webpack-client.browser.development.js:881:1)
    at resolveModelChunk (react-server-dom-webpack-client.browser.development.js:858:1)
    at processFullBinaryRow (react-server-dom-webpack-client.browser.development.js:1823:1)
    at progress (react-server-dom-webpack-client.browser.development.js:1974:1)

The above error occurred in the <NotFoundErrorBoundary> component.

React will try to recreate this component tree from scratch using the error boundary you provided, ReactDevOverlay.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro
  Available memory (MB): 65459
  Available CPU cores: 24
Binaries:
  Node: 20.16.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 15.0.0-canary.93 // There is a newer canary version (15.0.0-canary.137) available, please upgrade!
  eslint-config-next: 15.0.0-canary.93
  react: 19.0.0-rc-e56f4ae3-20240830
  react-dom: 19.0.0-rc-e56f4ae3-20240830
  typescript: 5.5.4
Next.js Config:
  output: N/A
 ⚠ There is a newer canary version (15.0.0-canary.137) 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)

Additional context

I have confirmed this issue is present is version 15.0.0-canary.93 and all following versions.
Version 15.0.0-canary.92 and earlier work without issues.
React was set to 19.0.0-rc-e56f4ae3-20240830 for all tests (however, I tested many React 19 RC versions from 4 months ago to date and it seemed to not affect the occurrence of the bug).

@mobeigi mobeigi added the bug Issue was opened via the bug report template. label Sep 1, 2024
@mobeigi mobeigi changed the title @svgr/webpack integration crashes on render inside server component (undefined error) @svgr/webpack integration crashes on render inside server component (undefined runtime error) Sep 1, 2024
@github-actions github-actions bot added the Runtime Related to Node.js or Edge Runtime with Next.js. label Sep 1, 2024
@mobeigi
Copy link
Contributor Author

mobeigi commented Sep 1, 2024

As a temporary workaround you can make the affected components client components using use client but this is obviously a bad workaround and not desirable.

I'm not quite sure if this is a Next / React bug, or @svgr/webpack due to breaking changes.

From https://github.com/vercel/next.js/releases/tag/v15.0.0-canary.93, the main relevant change is:
Update React from 6230622a1a-20240610 to 3208e73e-20240730

Which points to a possible React bug or incompatibility due to breaking changes.

v1s10n-4 added a commit to v1s10n-4/invaded-map that referenced this issue Sep 17, 2024
it seems to be this one: vercel/next.js#69545
as suggested [here](vercel/next.js#69545 (comment))
a possible workaround could be to turn svgr components into client components
v1s10n-4 added a commit to v1s10n-4/invaded-map that referenced this issue Sep 21, 2024
* feat(notification): init novu

* [IVD-57] Migrate to radix themes (#72)

* feat(UI): setup radix-theme

* feat(UI): use custom radix theme color

* feat(UI): migrate highscore pages to radix-theme

* chore(ui): init base layout from shadcn block 'dashboard-05'

* chore(deps): update vaul drawer module to latest minor

* feat: try to implement custom Spinner with css only

* chore(WIP): better invader loader + help page + layout

* feat: tricky but working custom spinner

* feat(UI): migrate help page to radix theme

* feat(UI): migrate help/thanks page to radix theme

* feat(UI): migrate legal pages to radix-ui

* feat(UI): root layout/drawer fixes w/ map page + better styles

* fix(UI): header top margin in PWA mode

* feat: move root drawer into its own component

* fix: breaking oklch colors handling on old devices

* feat(UI): use RootDrawer in root layout + add global scroll handling

* feat(UI): use new Spinner in root loading page

* feat(UI): use radix-theme classes for Drawer + remove overlay

* feat(UI): add padding for scrollbar in legal pages

* fix(UI): map page sizing + new loader

* perf: reduce costs by disabling /list image optimization

* fix(UI): add 'content' id to root layout for map sheet

* chore(UI): fix styles + add /help link in RootDrawer

* feat(UI): migrate most of /list to radix-theme + pwa scroll fixes

* feat(UI): migrate /map/[invaderName] to radix-themes

* chore(UI): use radix-theme for carousel buttons

* chore(UI): use radix-theme for SliderActions

* feat(UI): use radix-theme in MapSheet

* chore(UI): migrate UserMarker to radix-theme

* chore(UI): migrate InvaderHit to radix-themes

* fix(UI): bring scroll snap back for /list

* feat(UI): use DropdownMenu radix-themes classes on radix MenuBar

* feat(UI): migrate /list MenuBar to radix-themes

* feat(UI): migrate SkeletonHit to radix-themes + random string ssr function

* chore(UI): use new skeleton prop + radius fix + few ui tweaks

* feat(UI): migrate /map page to radix-themes

* fix: tweak MapSheet Header padding

* chore(UI): migrate Card to radix-theme

* feat: add shadow to Card component + better padding

* chore(UI): migrate CardForm to radix-themes

* feat(UI): migrate /account to radix-theme + FileInput component

* feat: rework AuthButton for RootHeader

* chore: add elevation to /list cards

* feat: add shadow to root header + better AuthButton skeleton

* feat(UI): revamp QR code drawer

* chore(UI): migrate ReferralLink section to radix-theme

* chore: ui fixes on RootDrawer and Drawer + LoginButton

* feat(UI): migrate /account header to radix-theme

* refactor: move /account header to its own component

* chore: complete Carousel migration to radix-theme

* feat(UI): migrate ReviewsSection to radix-ui

* feat(UI): /account review section skeleton

* feat: migrate ReviewCard to radix-theme

* feat(UI): migrate EditModal to radix-theme

* feat(UI): migrate invader history modal to radix-theme

* perf: reduce root drawer open delay

* feat(UI): added new desktop navigation menu (UI regression on iOS /list on drawer open)

* fix(GPU): [temp] iOS Safari crash when opening drawer on /list

* Upgrade React, Nextjs, NextAuth, Drizzle, vercel-postgres + fix local DB timeout + remove daisyUI (#73)

* fix: AuthButton new props on instances

* feat: use stable version for nextjs14 + react 19

* chore: update browserlist-lite

* refacto: remove unused imports

* refactor: remove unused components + move Single instance component closer to their page

* feat: invader history skeleton

* refacto: move Spinner image to public

* feat: get rid of daisy-ui classes + many small ui fixs and tweaks

* chore: remove daisyui from deps

* fix: build warnings about css nesting

* fix(/account): move server actions to proper files

* fix: missing name for StateForm

* fix(/map/[invaderName]): move server actions to proper files

* chore: allow api access from browser in local

* feat: upgrade auth.js drizzle @vercel/postgres + fix local db timeout + migration for users

* [FEAT] Custom Theme Panel + Themed Map styles (#74)

* feat(/map): [WIP] change map colors with theme ones

* fix: wrong bg on map IconButtons

* feat: mix grays and accent colors for dynamic map styles

* feat(map): bigger gap between gray/accent colors

* feat: added custom ThemePanel

* fix: tricky fix for map untouchable after dialog close

* fix: revert gap on RootDrawer items

* fix: tweak dirty fix timeout

* [FEATURE] map styles from current theme + custom theme panel (#75)

* feat(/map): [WIP] change map colors with theme ones

* fix: wrong bg on map IconButtons

* feat: mix grays and accent colors for dynamic map styles

* feat(map): bigger gap between gray/accent colors

* feat: added custom ThemePanel

* fix: tricky fix for map untouchable after dialog close

* fix: revert gap on RootDrawer items

* fix: tweak dirty fix timeout

* [CHORE] use our radix-themes fork + Nextjs 15 upgrade (#76)

* fix: use radix themes fork + upgrade next/react/vaul

* chore: migrate import to use radix theme fork

* chore: keep GET route handlers cached

* fix: keep our app requests cached by defautlt

* fix: keep client cache as it was in next14

* fix: migrate to @vercel/functions for ip geolocation

* fix: wrong naming for route handlers config option

* fix: remove deprecated Geo type

* fix: use drizzle directly for sitemap generation + handle errors

* fix: switch trustHost to true, don't really know why

* feat: enable react-compiler + eslint plugin

* fix: map types by avoiding using google global

* fix: dark grays are no longer the light ones

* fix: edge function timeout test

* Revert "fix: edge function timeout test"

This reverts commit 30ee7a6.

* feat(notification): init novu

* feat: add novu react basic implementation

* fix: URL.canParse polyfill for nextjs dev overlay

- the error only happen on safari <17 (iOS, macOS)
- it is triggered by vercel/next.js@a5e2a02#diff-daba055a3db9875013f17e3c82552acb4a81cf3cabd60ca168a7263285afaf3dR18-R21
- don't know why nextjs default browserslist doesn't make the official polyfill load

* feat: init notification center

* fix: notification refresh by updating novu/react

* feat: added basic notification center that works

* feat: use real props for novu client provider

* feat(notification): identify user to novu on login

* feat(notification): added contribution review workflow

* fix(edge): @novu/framework using crypto...

* fix: weird random error about $$typeof

it seems to be this one: vercel/next.js#69545
as suggested [here](vercel/next.js#69545 (comment))
a possible workaround could be to turn svgr components into client components

* fix: another unknown bug about file upload

could be JPG => AVIF conversion that fails or take too long
@unstubbable unstubbable self-assigned this Sep 23, 2024
@unstubbable unstubbable added the Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.). label Sep 23, 2024
unstubbable added a commit to unstubbable/react that referenced this issue Sep 23, 2024
unstubbable added a commit to unstubbable/react that referenced this issue Sep 23, 2024
sebmarkbage pushed a commit to facebook/react that referenced this issue Sep 24, 2024
This is a follow-up from #30528 to not only handle props (the critical
change), but also the owner ~and stack~ of a referenced element.

~Handling stacks here is rather academic because the Flight Server
currently does not deduplicate owner stacks. And if they are really
identical, we should probably just dedupe the whole element.~ EDIT:
Removed from the PR.

Handling owner objects on the other hand is an actual requirement as
reported in vercel/next.js#69545. This problem
only affects the stable release channel, as the absence of owner stacks
allows for the specific kind of shared owner deduping as demonstrated in
the unit test.
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked Runtime Related to Node.js or Edge Runtime with Next.js. Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).
Projects
None yet
2 participants