Repository navigation
feat: support split edge functions #17022
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
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b434b4d
feat(adapter-netlify): support split edge functions
teemingc 85c199b
Potential fix for pull request finding 'CodeQL / Incomplete string es…
teemingc 5e90577
fix(adapter-netlify): avoid split function name collisions
teemingc 94d5432
Merge remote-tracking branch 'origin/version-3' into teemingc-netlify…
teemingc c1ff9fb
refactor(adapter-netlify): share function module generation
teemingc 1b6f822
Update index.js
teemingc c15da59
test(adapter-netlify): check split outputs by runtime
teemingc e6225ee
Update test.js
teemingc 77b8cd9
test(adapter-netlify): avoid catch-all collision fixture
teemingc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@sveltejs/adapter-netlify': minor | ||
| --- | ||
|
|
||
| feat: support using `edge` and `split` together |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,42 @@ | ||
| import { server } from '0SERVER'; | ||
| /** @param {import('@sveltejs/kit').Server} server */ | ||
| export function init(server) { | ||
| /** | ||
| * We don't know the origin until we receive a request, but | ||
| * that's guaranteed to happen before we call `read` | ||
| * @type {string} | ||
| */ | ||
| let origin; | ||
|
|
||
| /** | ||
| * We don't know the origin until we receive a request, but | ||
| * that's guaranteed to happen before we call `read` | ||
| * @type {string} | ||
| */ | ||
| let origin; | ||
| const initialized = server.init({ | ||
| env: Deno.env.toObject(), | ||
| read: async (file) => { | ||
| const url = `${origin}/${file}`; | ||
| const response = await fetch(url); | ||
|
|
||
| const initialized = server.init({ | ||
| env: Deno.env.toObject(), | ||
| read: async (file) => { | ||
| const url = `${origin}/${file}`; | ||
| const response = await fetch(url); | ||
| if (!response.ok) { | ||
| throw new Error( | ||
| `read(...) failed: could not fetch ${url} (${response.status} ${response.statusText})` | ||
| ); | ||
| } | ||
|
|
||
| if (!response.ok) { | ||
| throw new Error( | ||
| `read(...) failed: could not fetch ${url} (${response.status} ${response.statusText})` | ||
| ); | ||
| return response.body; | ||
| } | ||
| }); | ||
|
|
||
| return response.body; | ||
| } | ||
| }); | ||
|
|
||
| /** @type {import('@netlify/edge-functions').EdgeFunction} */ | ||
| export default async function handler(request, context) { | ||
| if (!origin) { | ||
| origin = new URL(request.url).origin; | ||
| } | ||
| /** @type {import('@netlify/edge-functions').EdgeFunction} */ | ||
| return async function handler(request, context) { | ||
| if (!origin) { | ||
| origin = new URL(request.url).origin; | ||
| } | ||
|
|
||
| // always await initialization to prevent race condition with concurrent requests | ||
| await initialized; | ||
| // always await initialization to prevent race condition with concurrent requests | ||
| await initialized; | ||
|
|
||
| return server.respond(request, { | ||
| platform: { context }, | ||
| getClientAddress() { | ||
| return context.ip; | ||
| } | ||
| }); | ||
| return server.respond(request, { | ||
| platform: { context }, | ||
| getClientAddress() { | ||
| return context.ip; | ||
| } | ||
| }); | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.