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

SSR Issue: window is not defined in release 2.0.1 #2187

Closed
RomainLanz opened this issue Jan 14, 2025 · 5 comments · Fixed by #2190
Closed

SSR Issue: window is not defined in release 2.0.1 #2187

RomainLanz opened this issue Jan 14, 2025 · 5 comments · Fixed by #2190

Comments

@RomainLanz
Copy link

RomainLanz commented Jan 14, 2025

Hey there! 👋🏻

It seems like this PR might have broken the SSR of a component with the latest release 2.0.1. I'm encountering the following error during SSR rendering:

window is not defined

The error traces back to this line in the source: node_modules/@inertiajs/core/src/eventHandler.ts:21:16

I attempted to debug the issue locally and tried a monkey patch, but the published code is minified, making it difficult to modify or apply any meaningful changes directly.

Would it be possible to investigate this further or publish a non-minified version for easier debugging?

Thank you for your help!

@RomainLanz
Copy link
Author

RomainLanz commented Jan 14, 2025

If anyone wants to reproduce the issue, they can quickly test it by creating a new AdonisJS application using the following command:

npm init adonisjs@latest inertia-bug -- -K=inertia --adapter=vue --ssr

Followed by:

cd inertia-bug
npm run dev

EDIT: We patched the AdonisJS starter kit to force @inertiajs/[email protected]. To reproduce the error, you will need to remove the override in the package.json.

@usback
Copy link

usback commented Jan 14, 2025

same issuss
error has window.history.scrollRestoration

window.history.scrollRestoration && (window.history.scrollRestoration = "manual");

ReferenceError: window is not defined
    at file:///Volumes/files/workspace/www/gatmrg/html/bootstrap/ssr/assets/vendors-fetch-CJXqMbdi.js:3153:1
    at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:485:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:109:5)

@jonjakoblich
Copy link

Same issue

@Makav3li94
Copy link

Same issue
window.history.scrollRestoration && (window.history.scrollRestoration = "manual");

@usback
Copy link

usback commented Jan 15, 2025

thank you

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.

4 participants