Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route level config not working for +server.js #8908

Closed
Smirow opened this issue Feb 6, 2023 · 4 comments · Fixed by #8933
Closed

Route level config not working for +server.js #8908

Smirow opened this issue Feb 6, 2023 · 4 comments · Fixed by #8933
Labels
bug Something isn't working

Comments

@Smirow
Copy link

Smirow commented Feb 6, 2023

Describe the bug

Route level config seems to be ignored for +server.js/ts

Reproduction

Deploy to Vercel with a route level config in +server.js/ts.

Logs

No response

System Info

No response

Severity

annoyance

Additional Information

No response

@Rich-Harris
Copy link
Member

'Reproduction' is not an optional field.

If this relates to ISR, there is a known issue we are currently investigating.

@Smirow
Copy link
Author

Smirow commented Feb 6, 2023

@Rich-Harris I thought that was pretty self-explanatory, but I guess it's not: https://github.com/Smirow/kit-issue-8908

Should create two lambdas as I defined a config in api/+server.ts :

export const config: Config = {
  memory: 512,
  split: true // not needed
};

But when deployed to Vercel (or built for Vercel) it is bundled with the other route. So it seems that config is getting ignored in routes defined by +server.ts files (as opposed to +page(.server).ts, ...).

@Smirow
Copy link
Author

Smirow commented Feb 7, 2023

So probably related to this as config are retrieved only if the route is a page:
EDIT: actually it may also come from upstream.

if (route.page) {
const nodes = await Promise.all(
[...route.page.layouts, route.page.leaf].map((n) => {
if (n !== undefined) return manifest._.nodes[n]();
})
);
const layouts = nodes.slice(0, -1);
const page = nodes.at(-1);
for (const layout of layouts) {
if (layout) {
validate_common_exports(layout.server, route.id);
validate_common_exports(layout.universal, route.id);
}
}
if (page) {
methods.add('GET');
if (page.server?.actions) methods.add('POST');
validate_page_server_exports(page.server, route.id);
validate_common_exports(page.universal, route.id);
}
const should_prerender = get_option(nodes, 'prerender');
prerender =
should_prerender === true ||
// Try prerendering if ssr is false and no server needed. Set it to 'auto' so that
// the route is not removed from the manifest, there could be a server load function.
// People can opt out of this behavior by explicitly setting prerender to false
(should_prerender !== false && get_option(nodes, 'ssr') === false && !page?.server?.actions
? 'auto'
: should_prerender ?? false);
config = get_config(nodes);
}

@msonnberger
Copy link
Contributor

Can confirm that if I specify runtime: nodejs18.x in a +server.ts file, the route still shows up inside .svelte-kit/vercel-tmp/fn-0/manifest.js whereas it doesn't if I do the same inside +page.ts.

envinfo:

System:
    OS: macOS 13.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 47.92 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.14.0 - ~/.n/bin/node
    Yarn: 1.22.19 - ~/Library/pnpm/yarn
    npm: 9.3.1 - ~/.n/bin/npm
  Browsers:
    Firefox Developer Edition: 110.0
    Safari: 16.2
  npmPackages:
    @sveltejs/adapter-vercel: 2.0.1 => 2.0.1 
    @sveltejs/kit: 1.5.0 => 1.5.0 
    svelte: 3.55.1 => 3.55.1 
    vite: 4.1.1 => 4.1.1 

dummdidumm added a commit that referenced this issue Feb 7, 2023
@dummdidumm dummdidumm added bug Something isn't working and removed awaiting submitter labels Feb 7, 2023
Rich-Harris pushed a commit that referenced this issue Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants