Skip to content

ref(core): Add shared ServerRequestOptions type across runtimes - #25579

Open
isaacs wants to merge 1 commit into
developfrom
isaacschlueter/js-3968-common-server-options-create-shared-type
Open

isaacs wants to merge 1 commit into
developfrom
isaacschlueter/js-3968-common-server-options-create-shared-type

Conversation

@isaacs

@isaacs isaacs commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Node, Deno, Bun and Cloudflare each have their own options for incoming HTTP requests, and the option sets drift. Bun.serve takes only maxRequestBodySize, and Cloudflare has no span options. When we add an option to one runtime, nothing reminds us to add it to the others.

ServerRequestOptions in @sentry/core/server lists the options that every incoming request integration should support. Each runtime options type is checked against it with CheckServerRequestOptions. The check lists the options that the runtime does not support yet, with a comment that says why. It fails to compile when a shared option is neither declared nor listed, when a listed option is declared, or when a callback written for the shared type does not fit the runtime option.

The runtime types do not extend the shared type. With extends, a new shared option would appear in every runtime type, supported or not, and nothing would fail to compile. Each runtime keeps its own declarations and docs.

Node and Bun now type the request in ignoreRequestBody as RequestOptions & HttpIncomingMessage. The value was always an IncomingMessage. Callbacks typed with RequestOptions still compile. The RequestOptions part is deprecated, for removal in v12.

A new BUGBOT rule flags an incoming request option that applies to more than one runtime but is not in the shared type.

There is no runtime behavior change.

Fixes JS-3968
Fixes #25570

@linear-code

linear-code Bot commented Oct 20, 2026

Copy link
Copy Markdown

JS-3968

@isaacs
isaacs added this pull request to stack #25589 October 20, 2026 22:30
@isaacs

isaacs commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

Bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit b8ffd22. Configure here.

@isaacs
isaacs marked this pull request as ready for review October 20, 2026 23:42
@isaacs
isaacs requested a review from a team as a code owner October 20, 2026 23:42
@isaacs
isaacs requested review from JPeer264 and mydea and removed request for a team October 20, 2026 23:42
@isaacs
isaacs force-pushed the isaacschlueter/js-3968-common-server-options-create-shared-type branch 2 times, most recently from f6dbbc1 to b8ffd22 Compare October 21, 2026 01:12
Node, Deno, Bun and Cloudflare each have their own options for incoming
HTTP requests, and the option sets drift. Bun.serve takes only
`maxRequestBodySize`, and Cloudflare has no span options. When we add
an option to one runtime, nothing reminds us to add it to the others.

`ServerRequestOptions` in `@sentry/core/server` lists the options that
every incoming request integration should support. Each runtime options
type is checked against it with `CheckServerRequestOptions`. The check
lists the options that the runtime does not support yet, with a comment
that says why. It fails to compile when a shared option is neither
declared nor listed, when a listed option is declared, or when a
callback written for the shared type does not fit the runtime option.

The runtime types do not extend the shared type. With `extends`, a new
shared option would appear in every runtime type, supported or not, and
nothing would fail to compile. Each runtime keeps its own declarations
and docs.

Node and Bun now type the request in `ignoreRequestBody` as
`RequestOptions & HttpIncomingMessage`. The value was always an
`IncomingMessage`. Callbacks typed with `RequestOptions` still compile.
The `RequestOptions` part is deprecated, for removal in v12.

A new BUGBOT rule flags an incoming request option that applies to more
than one runtime but is not in the shared type.

There is no runtime behavior change.

Fixes JS-3968
Fixes #25570

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@isaacs
isaacs force-pushed the isaacschlueter/js-3968-common-server-options-create-shared-type branch from b8ffd22 to 80afcb3 Compare October 21, 2026 01:15
HttpOptions,
HttpIncomingMessage,
HttpServerResponse,
// Not supported yet.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

q: To double check. Going up the PR stack, I see that onSpanEnd is being supported then right? So this is here only temporarily?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This branch has not been deployed

No deployments
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.

Common Server Options: create shared type

2 participants