Skip to content

Commit

Permalink
throw error if isr route uses edge runtime (#9432)
Browse files Browse the repository at this point in the history
* throw error if isr route uses edge runtime

* please prettier

---------

Co-authored-by: Rich Harris <[email protected]>
Co-authored-by: Simon H <[email protected]>
  • Loading branch information
3 people authored Mar 16, 2023
1 parent 385bd49 commit a20069e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/many-shrimps-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-vercel': patch
---

fix: throw error if `isr` is combined with `runtime: 'edge'`
12 changes: 11 additions & 1 deletion packages/adapter-vercel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,18 @@ const plugin = function (defaults = {}) {
const config = { runtime, ...defaults, ...route.config };

if (config.isr) {
const directory = path.relative('.', builder.config.kit.files.routes + route.id);

if (runtime !== 'nodejs16.x' && runtime !== 'nodejs18.x') {
throw new Error(
`${directory}: Routes using \`isr\` must use either \`runtime: 'nodejs16.x'\` or \`runtime: 'nodejs18.x'\``
);
}

if (config.isr.allowQuery?.includes('__pathname')) {
throw new Error('__pathname is a reserved query parameter for isr.allowQuery');
throw new Error(
`${directory}: \`__pathname\` is a reserved query parameter for \`isr.allowQuery\``
);
}

isr_config.set(route, {
Expand Down

0 comments on commit a20069e

Please sign in to comment.