`adapter-static` and nonprerendered `+layout/page.server.js` files
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the bug
Hey folks,
I ran into a bit of an edge-case recently while trying to make a hybrid web + Tauri application (web uses adapter-node, Tauri creates an SPA using adapter-static). If there exists a +page.server.js or +layout.server.js file that exports a load() function, running the SPA via a basic web server will throw a 500 internal error, complaining that /__data.json cannot be found. I'm curious if this is an intended bug or if there is a workaround to it.
Reproduction
- Clone this repo and this branch.
- Run
pnpm install. - Run
pnpm build. - Using a basic web server tool (I used http-server), start a server (
http-server build). - Attempt to load in the web browser
Moving or deleting the +layout.server.js file will fix the issue.
Logs
[2022-11-13T23:31:19.546Z] "GET /" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
(node:83494) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
(Use `node --trace-deprecation ...` to show where the warning was created)
[2022-11-13T23:31:19.576Z] "GET /_app/immutable/start-39da41f2.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
[2022-11-13T23:31:19.578Z] "GET /_app/immutable/chunks/index-4ce6debf.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
[2022-11-13T23:31:19.579Z] "GET /_app/immutable/chunks/singletons-eb12c85b.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
[2022-11-13T23:31:19.589Z] "GET /_app/immutable/chunks/0-bc3f1161.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
[2022-11-13T23:31:19.590Z] "GET /_app/immutable/chunks/_layout-b03384d3.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
[2022-11-13T23:31:19.592Z] "GET /_app/immutable/components/layout.svelte-3895ce33.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
[2022-11-13T23:31:19.592Z] "GET /_app/immutable/chunks/1-f4967476.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
[2022-11-13T23:31:19.596Z] "GET /_app/immutable/chunks/2-9d7f729d.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
[2022-11-13T23:31:19.597Z] "GET /_app/immutable/components/error.svelte-52072039.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
[2022-11-13T23:31:19.600Z] "GET /_app/immutable/components/pages/_page.svelte-6481b931.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
[2022-11-13T23:31:19.603Z] "GET /__data.json" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
[2022-11-13T23:31:19.604Z] "GET /__data.json" Error (404): "Not found"
[2022-11-13T23:31:19.607Z] "GET /__data.json" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
[2022-11-13T23:31:19.607Z] "GET /__data.json" Error (404): "Not found"
[2022-11-13T23:31:19.611Z] "GET /_app/version.json" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
System Info
System:
OS: macOS 12.3.1
CPU: (10) arm64 Apple M1 Pro
Memory: 112.78 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 18.9.0 - ~/.asdf/installs/nodejs/18.9.0/bin/node
npm: 8.19.1 - ~/.asdf/plugins/nodejs/shims/npm
Browsers:
Brave Browser: 107.1.45.123
Safari: 15.4
npmPackages:
@sveltejs/adapter-static: 1.0.0-next.48 => 1.0.0-next.48
@sveltejs/kit: 1.0.0-next.544 => 1.0.0-next.544
svelte: ^3.53.1 => 3.53.1
vite: ^3.2.3 => 3.2.3
Severity
blocking all usage of SvelteKit
Additional Information
Obviously this isn't completely blocking, from a web standpoint, but it is blocking me from creating a production build of my Tauri app, as I can't create the SPA and my web version (which SSR'd) needs the cookie information passed from +layout.server.js.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked nickersoft/static-server reproduction, then inspect how adapter-static handles +layout.server.js and +page.server.js during pnpm build. Serve the generated build directory with http-server and verify that loading the SPA no longer fails on /__data.json, while the web build can still receive cookie information from +layout.server.js.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, tauri, vite
- Domain
- build-system, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100