kit: Mobile iOS Safari Errors - 500: Importing a module script failed.

Describe the bug

I recently migrated my website from NextJS to SvelteKit.

Everything has worked smoothly except for mysterious errors that seem to happen mostly on mobile iOS Safari, but also on desktop Firefox.

On Safari, the error is: “500: Importing a module script failed.” On Firefox, the error is: “500: error loading dynamically imported module”

Screenshot 2022-06-15 at 16 26 18

As you can see, this is so common that a total of 0.6% of visitors are getting a critical error that is severe enough to replace the entire page’s content with an error message.

On Safari, the error happens mostly on the home page. On Firefox there is no noticeable pattern. It appears to be a client-side error because my Vercel server logs are not picking up the errors.

I track the error by sending a custom event to Plausible Analytics in the __error.svelte file.

The error appears to be coming from up-to-date browser versions. As in, Safari 15 and Firefox 101.

Here’s the spike in errors after switching to SvelteKit:

Screenshot 2022-06-15 at 16 34 13

Unfortunately, I am totally unable to replicate the error myself. It does not show up on my iPhone or the versions I tested with Browserstack. And there doesn’t appear to be any stack trace provided to help me debug the issue.

This is my site: https://stockanalysis.com/ This is the repo: https://github.com/stockanalysisdev/stock-analysis-sveltekit

Has anyone dealt with this issue before? Or have an idea about the best way to debug the issue without being able to reproduce it myself?

Also, if anyone could try visiting my home page on mobile iOS Safari and see whether they get an error and a stack trace then that would be incredibly helpful.

Reproduction

Unable to reproduce testing on my own iPhone or via Browserstack.

Logs

No response

System Info

All packages have been updated to their latest versions.

System:
    OS: macOS 12.4
    CPU: (10) x64 Apple M1 Pro
    Memory: 333.49 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 17.9.0 - /usr/local/bin/node
    npm: 8.8.0 - /usr/local/bin/npm
  Browsers:
    Brave Browser: 102.1.39.122
    Chrome: 102.0.5005.115
    Firefox: 101.0.1
    Safari: 15.5
  npmPackages:
    @sveltejs/adapter-auto: 1.0.0-next.50 => 1.0.0-next.50 
    @sveltejs/kit: 1.0.0-next.350 => 1.0.0-next.350 
    svelte: ^3.48.0 => 3.48.0

Severity

blocking an upgrade

Additional Information

No response

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 25 (5 by maintainers)

Most upvoted comments

I don’t mean to beat a dead horse here, but my application is a PWA Svelte (but not SvelteKit) and getting these errors reported. I would imagine this may be still present in SvelteKit, but the reason I’m posting here is because a lot of my users are experiencing this error and I have no strings to pull on except in this thread. Does anyone understand why this is happening? Has anybody found a solution?

  1. you have code splitting in your app.
  2. the user visits your website and loads only part of your code split app.
  3. you deploy a new version
  4. the user does not reload the page, so it is running an old script with references to code split bundles that no longer exist on your server.
  5. the browser makes a request for code split modules that no longer exist.

Vercel, it looks like, behind Cloudflare.

That said, I’m not sure that there’s anything we can or should do here about this. In my experience, client-side error reporting services report a ton of truly bonkers errors, and these don’t seem to correlate at all with getting complaints from real people that the app is not working properly. If this isn’t something that can be consistently reproduced, and isn’t something that can be traced to SvelteKit rather than “iunno browsers freak out sometimes, especially Safari”, then I’d be in favor of closing this.

We have the same problem on osx and ios with safari.

Bildschirmfoto 2025-01-03 um 20 02 37 Bildschirmfoto 2025-01-03 um 20 02 57

I’m also getting similar reports on Safari browsers.

I’m seeing sentry reporting this issue persistently for safari users: image (LINE being a mobile safari based browser) There are no additional stack trace details for some reason.

I’m going to close this since the error rate has gone down significantly. It’s down to about 0.3% of visits, which is significant but not much higher than it was with NextJS.

I haven’t done anything specific that I belive can explain the drop in errors. They increased with Vite 3.0.0 but have gone down as of Vite 3.0.2. Not sure if that’s even related to the errors.