Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ jobs:
with:
node-version: ${{matrix.node-version}}
cache: pnpm
# required for testing netlify edge functions
- uses: denoland/setup-deno@v2
with:
deno-version: ^2.2.4
Comment on lines +233 to +236
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very familiar with GitHub actions and CI. Installing deno this way solves our issue explained here #14686 (comment) . Does adding this have any implications I'm not aware of?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a fan of this. why can't it run on node? If we allow this, would we consider adding others for vercel, bun or whatnot in the future?

if we want to test the runtime part of adapters, it should probably be in a separate workflow to create tailored environments for the adapter. The one here is not really matching netlify at all as there's not only deno but a host of other things that isn't present there.

Copy link
Member

@teemingc teemingc Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Netlify edge functions run on the Deno runtime so it tries to install it when spinning up a Netlify edge function for the preview server. Currently, we have workerd too for Cloudflare that's installed along with Wrangler when we run Cloudflare tests. I don't know why @netlify/dev doesn't work similarly.

So far, Vercel has nothing we can run locally so I think we're suppose to set up deployments for tests at some point (or maybe we should do this for all of them?)

Should we split up the adapter tests into their own workflows?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this also require deno for local testing? In this case it would have to be documented in our contributing and i think that makes an even stronger case for separating it out into a separate test script.

Copy link
Member

@teemingc teemingc Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprisingly not. It just works when running it locally but not in CI due to permission settings. Maybe @serhalp can weigh in on how to best handle this. I'll dig into the @netlify/dev code later to see how it's handled

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isolation is also about execution time and resources. why add deno to a test matrix with a node dimension if it's hardly used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine the installation should get cached. Splitting into new jobs also means that we're paying some setup costs in each of the jobs which will burn more total CI minutes

Copy link
Member

@teemingc teemingc Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do wonder about Ben's point but I'm not sure where the greater cost lies. It does make a lot of sense to separate the build tests from the runtime tests (especially for cloudflare and netlify edge which will be the exact same in each node matrix). But I think we don't have many runtime tests yet to truly benefit from this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, avoiding running them on multiple versions of Node when we don't even run them in Node is a pretty good argument. I hadn't thought about that. It will save us total CI minutes and probably finish faster on average, so I'd be in favor if it's something you want to take on

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created an issue for that here #15175 it will probably be useful when we have more Cloudflare/Netlify tests after we've added the environment API

- run: pnpm install --frozen-lockfile
- run: pnpm playwright install chromium
- run: cd packages/kit && pnpm prepublishOnly
Expand Down
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"files": [
"**/CHANGELOG.md",
"**/vite.config.js.timestamp-*",
"**/.netlify/**",
"**/.svelte-kit/**",
"**/.custom-out-dir/**",
"**/test-results/**",
Expand All @@ -32,7 +33,7 @@
"packages/package/test/watch/package/**/*",
"packages/kit/src/core/postbuild/fixtures/**/*",
"packages/adapter-cloudflare/test/apps/workers/dist/**/*",
"packages/*/test/**/build"
"packages/*/test/**/build/**"
],
"options": {
"rangeEnd": 0
Expand Down
4 changes: 3 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default [
{
ignores: [
'**/.svelte-kit',
'**/.netlify',
'**/.wrangler',
'**/test-results',
'**/build',
Expand Down Expand Up @@ -59,7 +60,8 @@ export default [
'packages/kit/test/apps/**/*',
'packages/kit/test/build-errors/**/*',
'packages/kit/test/prerendering/**/*',
'packages/test-redirect-importer/index.js'
'packages/test-redirect-importer/index.js',
'packages/adapter-netlify/test/preview.js'
]
}
];
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"onlyBuiltDependencies": [
"@parcel/watcher",
"esbuild",
"netlify-cli",
"protobufjs",
"rolldown",
"sharp",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-netlify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ function generate_lambda_functions({ builder, publish, split }) {
'0SERVER': './server/index.js' // digit prefix prevents CJS build from using this as a variable name, which would also get replaced
};

builder.copy(files, '.netlify', { replace });
builder.copy(files, '.netlify', { replace, filter: (name) => !name.endsWith('edge.js') });

// Configuring the function to use ESM as the output format.
const fn_config = JSON.stringify({ config: { nodeModuleFormat: 'esm' }, version: 1 });
Expand Down
1 change: 1 addition & 0 deletions packages/adapter-netlify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"set-cookie-parser": "^2.6.0"
},
"devDependencies": {
"@netlify/dev": "catalog:",
"@netlify/edge-functions": "catalog:",
"@netlify/functions": "catalog:",
"@netlify/node-cookies": "^0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-netlify/test/apps/basic/netlify.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[dev]
publish = "build"
publish = "build"
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// This is a temporary workaround to be compatible with Netlify's new dev server
// TODO: remove this once we overhaul the Netlify adapter to use Netlify's new serverless function format https://docs.netlify.com/build/functions/get-started/?data-tab=TypeScript#write-a-function

import { handler } from '../../.netlify/functions-internal/sveltekit-render.mjs';

/**
* @param {Request} request
* @param {import('@netlify/functions').HandlerContext} context
*/
export default async function (request, context) {
const [rawUrl, rawQuery] = request.url.split('?');
/** @type {import('@netlify/functions').HandlerEvent} */
const event = {
rawUrl,
rawQuery: rawQuery || '',
headers: Object.fromEntries(request.headers),
httpMethod: request.method,
isBase64Encoded: false,
path: new URL(request.url).pathname,
queryStringParameters: Object.fromEntries(new URL(request.url).searchParams),
body: request.body && (await request.text()),
multiValueHeaders: {},
multiValueQueryStringParameters: null
};
const result = await handler(event, context);
if (result) {
return new Response(result.body, {
status: result.statusCode,
// @ts-ignore
headers: result.headers
});
}

return new Response('Not Found', { status: 404 });
}

export const config = {
path: '/*'
};
3 changes: 1 addition & 2 deletions packages/adapter-netlify/test/apps/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "BROWSER=none netlify serve",
"preview": "node ../../preview.js",
"prepare": "svelte-kit sync || echo ''",
"test": "playwright test"
},
"devDependencies": {
"@sveltejs/kit": "workspace:^",
"@sveltejs/vite-plugin-svelte": "catalog:",
"netlify-cli": "catalog:",
"svelte": "catalog:",
"vite": "catalog:"
},
Expand Down
15 changes: 14 additions & 1 deletion packages/adapter-netlify/test/apps/edge/netlify.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
[dev]
publish = "build"
publish = "build"

# TODO: remove these once we overhaul the Netlify adapter to use the new edge declarations https://docs.netlify.com/build/edge-functions/declarations/#declare-edge-functions-inline

[build]
# defaults to "netlify/edge-functions" (without the . prefix)
edge_functions = ".netlify/edge-functions"

# the dev server doesn't read the manifest.json in edge-functions so we need
# to explicitly declare this here
[[edge_functions]]
path = "/*"
function = "render"
excludedPath = ["/_app/immutable/*", "/_app/version.json", "/.netlify/*"]
3 changes: 1 addition & 2 deletions packages/adapter-netlify/test/apps/edge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "BROWSER=none netlify serve",
"preview": "node ../../preview.js",
"prepare": "svelte-kit sync || echo ''",
"test": "playwright test"
},
"devDependencies": {
"@sveltejs/kit": "workspace:^",
"@sveltejs/vite-plugin-svelte": "catalog:",
"netlify-cli": "catalog:",
"svelte": "catalog:",
"vite": "catalog:"
},
Expand Down
24 changes: 24 additions & 0 deletions packages/adapter-netlify/test/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// This allows us to run `netlify dev` without installing the Netlify CLI
// Don't include this file in type checking because @netlify/dev has transitive imports with type errors
import { NetlifyDev } from '@netlify/dev';
import http from 'node:http';
import process from 'node:process';
import { getRequest, setResponse } from '@sveltejs/kit/node';

const netlifyDev = new NetlifyDev({});

const serverReady = netlifyDev.start();

const port = process.env.PORT ? +process.env.PORT : 8888;
const base = `http://localhost:${port}`;

http
.createServer(async (req, res) => {
await serverReady;
const request = await getRequest({ request: req, base });
const response =
(await netlifyDev.handle(request)) ?? new Response('Not Found', { status: 404 });
await setResponse(res, response);
})
.listen(port);
console.log(`Netlify Dev listening on http://localhost:${port}`);
4 changes: 3 additions & 1 deletion packages/adapter-node/src/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ function normalise_header(name, value) {
* @returns {string}
*/
function get_origin(headers) {
const protocol = decodeURIComponent(normalise_header(protocol_header, headers[protocol_header]) || 'https');
const protocol = decodeURIComponent(
normalise_header(protocol_header, headers[protocol_header]) || 'https'
);

// this helps us avoid host injections through the protocol header
if (protocol.includes(':')) {
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2769,7 +2769,7 @@ declare module '@sveltejs/kit' {
class Redirect_1 {

constructor(status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308, location: string);
status: 301 | 302 | 303 | 307 | 308 | 300 | 304 | 305 | 306;
status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308;
location: string;
}

Expand Down
Loading
Loading