Pages some assets throw 500

Is there any update on this issue? I’m experiencing similar issues.

Can you please provide some details?

Absolutely. I have a Sveltekit site with the Cloudflare adapter, and the site works some of the time.

The current issue is: When loading the site, I will get a “ReferenceError: window is not defined”. Which suggests that in a function I’m either doing something with the window object or importing some package that is. However, if I just hit refresh on the page, the error goes away and the page loads correctly.

Here’s a gif showing the issue: https://imgur.com/BeXB6ne

I’ve noticed that if I haven’t hit the page for 10 minutes or so, it will give the error, then if I refresh a few seconds later, it will not have the error. This leads me to believe there’s some kind of difference between a cold start and a warm start (ie cached vs not cached). I might be running into the 10ms limit of functions, tho there are no errors on the CF Pages dashboard.

By now there’s a few different preview deployment that have the same issue, so let me share 2 of them:
https://3cd82c16.quest-admin.pages.dev/
https://cc0a2e22.quest-admin.pages.dev/

Here’s some different things I’ve tried:
The ‘thing’ that causes the error seems to be the ‘’ (which is a standard SvelteKit thing to indicate where a template should be rendered)

A completely clean SvelteKit project does seem to work correctly, which is why I’m thinking I might be running into 10ms limit. This project is bigger than an clean new project.

Unfortunately there’s no way to create a ticket as a free-tier user, as I’m sure an employee would be able to give more insight into the error. And also I don’t know how to print more information about the error.

The sporadic nature of the error makes me think it’s not my code. Tho I’m happy to be proven wrong. It’s client code tho, so I can’t just share the repo.

Are you using window in any of your SvelteKit <script> tags on the site?

This doesn’t sound like a Pages error, more that SvelteKit is trying to access window (and failing because it’s server-side rendered).

If you are not using window then it may be a library that you are importing, I’d suggest slowly removing libraries and trying again until the error goes away.

Yeah that is definitely not an error on our side, I’d follow what @mcfadyeni said.

1 Like

Okay, that’s a fair conclusion. The thing that confuses me then is how to explain the “Refresh and it works” thing? Shouldn’t it just always throw the error?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.