Skip to content

Prerendered dependencies are SSR'd in production #3849

Closed
@Rich-Harris

Description

@Rich-Harris

Describe the bug

The second half of #3848https://kit.svelte.dev/docs is failing at the moment because (AFAICT) it's attempting to server-render /docs.json which was (necessarily, because it uses the filesystem) prerendered during build.

SvelteKit has logic for loading e.g. static/docs.json via fetch rather than attempting to server-render it here...

if (is_asset || is_asset_html) {
const file = is_asset ? filename : filename_html;
if (options.read) {
const type = is_asset
? options.manifest._.mime[filename.slice(filename.lastIndexOf('.'))]
: 'text/html';
response = new Response(options.read(file), {
headers: type ? { 'content-type': type } : {}
});
} else {
response = await fetch(`${url.origin}/${file}`, /** @type {RequestInit} */ (opts));
}
} else if (is_root_relative(resolved)) {
...but it's not applying that same logic to files that were generated during prerendering.

Reproduction

go to https://kit.svelte.dev/docs

Logs

No response

System Info

System:
    OS: macOS 12.0.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 89.55 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
  Browsers:
    Chrome: 98.0.4758.80
    Firefox: 96.0.3
    Safari: 15.1
  npmPackages:
    @sveltejs/vite-plugin-svelte: ^1.0.0-next.32 => 1.0.0-next.32 
    svelte: ^3.44.2 => 3.44.2 
    vite: ^2.8.0 => 2.8.0

Severity

serious, but I can work around it

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedPRs welcomed. The implementation details are unlikely to cause debatep1-importantSvelteKit cannot be used by a large number of people, basic functionality is missing, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions