Skip to content

adapter-static and nonprerendered +layout/page.server.js files #7637

@Nickersoft

Description

@Nickersoft

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.

image

image

Reproduction

  1. Clone this repo and this branch.
  2. Run pnpm install.
  3. Run pnpm build.
  4. Using a basic web server tool (I used http-server), start a server (http-server build).
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions