-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat: Respect abort signals during serverside fetch optimization #13877
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
Merged
elliott-with-the-longest-name-on-github
merged 5 commits into
main
from
elliott/respect-abort-signals
Jun 12, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f4251a5
feat: Respect abort signals during serverside fetch optimization
elliott-with-the-longest-name-on-github 4ca2e17
move
elliott-with-the-longest-name-on-github edd8be2
lint
elliott-with-the-longest-name-on-github 53696bf
snake_case
elliott-with-the-longest-name-on-github d169997
chore: Remove abort listener
elliott-with-the-longest-name-on-github 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
31 changes: 31 additions & 0 deletions
31
packages/kit/test/apps/basics/src/routes/load/fetch-abort-signal/+page.server.js
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,31 @@ | ||
export async function load({ fetch }) { | ||
const aborted_controller = new AbortController(); | ||
aborted_controller.abort(); | ||
|
||
let aborted_immediately = false; | ||
try { | ||
await fetch('/load/fetch-abort-signal/data', { signal: aborted_controller.signal }); | ||
} catch (error) { | ||
if (error.name === 'AbortError') { | ||
aborted_immediately = true; | ||
} | ||
} | ||
|
||
let aborted_during_request = false; | ||
try { | ||
await fetch('/load/fetch-abort-signal/slow', { signal: AbortSignal.timeout(100) }); | ||
} catch (error) { | ||
if (error.name === 'AbortError') { | ||
aborted_during_request = true; | ||
} | ||
} | ||
|
||
const successful_response = await fetch('/load/fetch-abort-signal/data'); | ||
const successful_data = await successful_response.json(); | ||
|
||
return { | ||
aborted_immediately, | ||
aborted_during_request, | ||
successful_data | ||
}; | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/kit/test/apps/basics/src/routes/load/fetch-abort-signal/+page.svelte
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,10 @@ | ||
<script> | ||
export let data; | ||
</script> | ||
|
||
<div> | ||
<h1>AbortSignal Test Results</h1> | ||
<p class="aborted-immediately">Aborted immediately: {data.aborted_immediately}</p> | ||
<p class="aborted-during-request">Aborted during request: {data.aborted_during_request}</p> | ||
<p class="successful-data">Successful data: {JSON.stringify(data.successful_data)}</p> | ||
</div> |
5 changes: 5 additions & 0 deletions
5
packages/kit/test/apps/basics/src/routes/load/fetch-abort-signal/data/+server.js
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 @@ | ||
import { json } from '@sveltejs/kit'; | ||
|
||
export async function GET() { | ||
return json({ message: 'success', timestamp: Date.now() }); | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/kit/test/apps/basics/src/routes/load/fetch-abort-signal/slow/+server.js
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,3 @@ | ||
export function GET() { | ||
return new Promise(() => {}); | ||
} |
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.
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.