Skip to content

feat: add signal property to request in vite, node environments #13895

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

orisrightpaw
Copy link

@orisrightpaw orisrightpaw commented Jun 17, 2025

Gives routes an AbortSignal (as present in the Request object) to know when the other end hangs up prematurely.

Fixes #12823 for vite dev+preview and @sveltejs/adapter-node


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

Copy link

changeset-bot bot commented Jun 17, 2025

🦋 Changeset detected

Latest commit: 1396477

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@sveltejs/adapter-node Minor
@sveltejs/kit Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@svelte-docs-bot
Copy link

@orisrightpaw
Copy link
Author

orisrightpaw commented Jun 17, 2025

Oops! This is a change to kit core too, not just the node adapter. 🤦

@orisrightpaw orisrightpaw changed the title feat: Add signal property for Request in @sveltejs/adapter-node feat: Add signal property for Requests Jun 17, 2025
@orisrightpaw
Copy link
Author

Demonstration repository

@orisrightpaw orisrightpaw marked this pull request as ready for review June 17, 2025 07:41
@@ -0,0 +1,6 @@
---
'@sveltejs/adapter-node': minor
Copy link
Member

Choose a reason for hiding this comment

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

this doesn't actually touch the adapter-node code at all

Suggested change
'@sveltejs/adapter-node': minor

Copy link
Member

Choose a reason for hiding this comment

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

It does touch @sveltejs/kit/node, though, and the Node adapter is bundled, so we need to re-build it and release a new version.

Copy link
Member

Choose a reason for hiding this comment

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

On that note, @sveltejs/kit/node's getRequest is also used in local development, in preview mode, and in production in the Vercel adapter. Is this going to have any impact on those?

Copy link
Author

Choose a reason for hiding this comment

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

On that note, @sveltejs/kit/node's getRequest is also used in local development, in preview mode, and in production in the Vercel adapter. Is this going to have any impact on those?

Yes, it would. Apologies for not being clearer. Though, I wasn't aware that the vercel adapter used getRequest. I'll mark @sveltejs/adapter-vercel for a minor version, as well.

@benmccann
Copy link
Member

this would need some documentation. possibly in the adapter-node docs

@orisrightpaw orisrightpaw changed the title feat: Add signal property for Requests feat: add signal property to request in vite, node, vercel environments Jun 17, 2025
@orisrightpaw
Copy link
Author

this would need some documentation. possibly in the adapter-node docs

Alright. I'll see what I can do.

@orisrightpaw orisrightpaw force-pushed the request-abortsignal branch from 12ff4b5 to 2654850 Compare June 18, 2025 04:14
@orisrightpaw
Copy link
Author

After a bit of testing behavior in Vercel, I couldn't get the request to hang up early without a body. It works fine on POST requests with data, but will not work on GET requests. I guess it's just a Vercel thing...? Someone else might be able to get it to work, but from what I can see, I don't think Vercel will tell you when the client cancels the request. I've removed the Vercel package from the changeset.

On another note though, I squashed my commits and wrote some documentation. It's under the adapter-node docs, as @benmccann suggested.

@orisrightpaw orisrightpaw changed the title feat: add signal property to request in vite, node, vercel environments feat: add signal property to request in vite, node environments Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose somehow on the event object that the incoming request connection has been closed
3 participants