Repository navigation
feat(deno): Record request sessions for Deno.serve - #25496
Conversation
|
Bugbot run |
`denoHttpIntegration` records a request session for each `node:http` request, but `denoServeIntegration` recorded none. Most Deno apps use `Deno.serve`, so release health showed no request sessions and no crash-free rate for them. The shared helper `recordRequestSession` waits for the `close` event of a `node:http` response, which `Deno.serve` does not have. Core now exports `startRequestSession`, which starts the session and returns an `end()` function. `recordRequestSession` keeps its signature and calls `end()` from the `close` event, so Node does not change. The helper now defaults `sessionFlushingDelayMS` to 60 seconds. Before, only core's `node:http` subscription code set that default, and a caller that left the option out got a timer that fired at once. `denoServeIntegration` accepts `sessions` (default `true`) and `sessionFlushingDelayMS`, as `denoHttpIntegration` does. The session ends when the response finishes. For a streamed response, that is when the stream finishes. When the handler throws, the session ends after the SDK captures the error, so it counts as crashed. Sessions do not depend on tracing, so they are also recorded when the SDK skips the span. To match Node, OPTIONS and HEAD requests also record sessions. Fixes #25495 Fixes JS-3956 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
e420c76 to
23896e3
Compare
size-limit report 📦
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 23896e3. Configure here.
| requestIsolationScope: isolationScope, | ||
| sessionFlushingDelayMS: integration.sessionFlushingDelayMS, | ||
| }) | ||
| : undefined; |
There was a problem hiding this comment.
Session timer blocks Deno process exit
Medium Severity
denoServeIntegration now ends request sessions through startRequestSession, which schedules a 60s aggregate setTimeout. safeUnref only calls unref() when the timer is an object, but Deno’s setTimeout returns a numeric id, so the timer stays referenced. After a Deno.serve request, a CLI or short-lived Deno process can sit in the event loop until that delay elapses, even when no release is set and sendSession will drop the aggregate.
Additional Locations (1)
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit 23896e3. Configure here.


denoHttpIntegrationrecords a request session for eachnode:httprequest, butdenoServeIntegrationrecorded none. Most Deno apps useDeno.serve, so release health showed no request sessions and no crash-free rate for them.The shared helper
recordRequestSessionwaits for thecloseevent of anode:httpresponse, whichDeno.servedoes not have. Core now exportsstartRequestSession, which starts the session and returns anend()function.recordRequestSessionkeeps its signature and callsend()from thecloseevent, so Node does not change. The helper now defaultssessionFlushingDelayMSto 60 seconds. Before, only core'snode:httpsubscription code set that default, and a caller that left the option out got a timer that fired at once.denoServeIntegrationacceptssessions(defaulttrue) andsessionFlushingDelayMS, asdenoHttpIntegrationdoes. The session ends when the response finishes. For a streamed response, that is when the stream finishes. When the handler throws, the session ends after the SDK captures the error, so it counts as crashed. Sessions do not depend on tracing, so they are also recorded when the SDK skips the span. To match Node, OPTIONS and HEAD requests also record sessions.Fixes #25495
Fixes JS-3956