kit: Getting 404 error during "npm run build", but not "npm run dev" (simple static adapter website)

Describe the bug

After a recent npm update (which I’m assuming updated Svelte, but correct me if I’m wrong), I’ve started getting a 404 error when attempting to do a release build. It doesn’t happen when I do a preview build (see attached image).

My site is a very simple static webpage (using adapter-static). No stub routing, no spaces in image filenames, etc.

Screenshot 2021-12-01 154845

Reproduction

See files I’ve attached here. Since this error occurs at build time (and not during website usage), I’m not sure how to respond to this.

My website is proprietary and thus not on Github. I can send the full repository to a Svelte maintainer via ProtonMail if necessary. Please advise.

tsconfig json svelte config js package json jsconfig json

Logs

I'm not sure what logs to include. If you need any, please advise. Thank you in advance for your help...

System Info

System:
    OS: Linux 5.10 Ubuntu 18.04.6 LTS (Bionic Beaver)
    CPU: (4) x64 Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz
    Memory: 3.90 GB / 6.08 GB
    Container: Yes
    Shell: 4.4.20 - /bin/bash
  Binaries:
    Node: 16.4.1 - ~/.nvs/node/16.4.1/x64/bin/node
    npm: 7.18.1 - ~/.nvs/node/16.4.1/x64/bin/npm
  npmPackages:
    @sveltejs/adapter-static: ^1.0.0-next.13 => 1.0.0-next.21
    @sveltejs/kit: next => 1.0.0-next.201
    svelte: ^3.34.0 => 3.44.2

Severity

blocking an upgrade

Additional Information

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 24 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Sorry, got a lot busy recently, but thanks for tracking this down! That means something in v200 failed, which is likely #2832. If someone wants to help out, feel free to debug that PR.

I also got problems after #2832, in my case it is a combination of the following:

  • my static site is not hosted the root of my domain, let’s say it in www.domain.com/test. I have added /test as base path and page/asset paths in svelte-config.
  • I have a 302 redirect that need to point to /test/page1
  • After updating svelte-kit (including #2832) the build process tries to crawl the redirected url (/test/page1), but it cannot find it, since it’s actually positioned at /page1 during the build process.

I added a work-around, by adding an extra empty route at /test/page1, which ‘works’ but it would be preferable if either:

  1. Svelte-kit accounts for base path when crawling redirects.
  2. You can somehow flag that you don’t want to crawl your redirects.

Both repros work correctly with the current version of SvelteKit, so whatever the bug was we can regard it as fixed — closing

The path to static files in release build with adapter-static has been an unresolved issue for at least 50 versions it seems, bizarre.

The index.svelte file shouldn’t be necessary, but I don’t remember anything that would cause that behaviour. I’ll take a deeper look at this tomorrow, but since you’ve mentioned that this only happen after an update in sveltekit/static, you can also try downgrading them and see which version breaks it. The changelog may help with it too.