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

[Bug]: Use of window.navigator breaks SSR usage #1755

Closed
metonym opened this issue Feb 19, 2024 · 2 comments · Fixed by #1756
Closed

[Bug]: Use of window.navigator breaks SSR usage #1755

metonym opened this issue Feb 19, 2024 · 2 comments · Fixed by #1756

Comments

@metonym
Copy link
Contributor

metonym commented Feb 19, 2024

Application/Team

N/A

What happened?

I upgraded my SvelteKit example to use the latest version (1.14.x), but experienced an error related to SSR.

window.navigator is a browser API, so it should be guarded against.

Stack trace leads to this line in configuration.ts:

code: navigator?.language || 'en-US', // read from browser's navigator.language

Related PR: #1751

Version

I first started seeing this in 1.14.x

1.13.x works fine.

Data & options used

See the example repo: https://github.com/metonym/carbon-charts-svelte-examples/tree/master/sveltekit

Relevant log output

9:42:37 AM [vite] Error when evaluating SSR module /node_modules/@carbon/charts-svelte/dist/AlluvialChart.svelte: failed to import "@carbon/charts"
|- ReferenceError: navigator is not defined
    at <redacted>/carbon-charts-svelte-examples/sveltekit/node_modules/@carbon/charts/dist/color-scale-utils-BosGSMyP.mjs:1867:10
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

9:42:37 AM [vite] Error when evaluating SSR module /node_modules/@carbon/charts-svelte/dist/index.js: failed to import "/node_modules/@carbon/charts-svelte/dist/AlluvialChart.svelte"
|- ReferenceError: navigator is not defined
    at <redacted>/carbon-charts-svelte-examples/sveltekit/node_modules/@carbon/charts/dist/color-scale-utils-BosGSMyP.mjs:1867:10
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

9:42:37 AM [vite] Error when evaluating SSR module /src/lib/Basic.svelte: failed to import "/node_modules/@carbon/charts-svelte/dist/index.js"
|- ReferenceError: navigator is not defined
    at <redacted>/carbon-charts-svelte-examples/sveltekit/node_modules/@carbon/charts/dist/color-scale-utils-BosGSMyP.mjs:1867:10
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

9:42:37 AM [vite] Error when evaluating SSR module /src/routes/+page.svelte: failed to import "/src/lib/Basic.svelte"
|- ReferenceError: navigator is not defined
    at <redacted>/carbon-charts-svelte-examples/sveltekit/node_modules/@carbon/charts/dist/color-scale-utils-BosGSMyP.mjs:1867:10
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

ReferenceError: navigator is not defined
    at <redacted>/carbon-charts-svelte-examples/sveltekit/node_modules/@carbon/charts/dist/color-scale-utils-BosGSMyP.mjs:1867:10
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

StackBlitz example

https://github.com/metonym/carbon-charts-svelte-examples/tree/master/sveltekit

What priority level would this be in your opinion?

P4

@metonym
Copy link
Contributor Author

metonym commented Feb 19, 2024

I marked this as a high priority bug as I believe it impacts all and any SSR usage.

@metonym
Copy link
Contributor Author

metonym commented Feb 19, 2024

If you're experiencing this, this is now patched in version 1.14.2.

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 a pull request may close this issue.

1 participant