René's URL Explorer Experiment


Title: node:http client span never ends when the response is destroyed without an error (res.destroy()) · Issue #25469 · getsentry/sentry-javascript · GitHub

Open Graph Title: node:http client span never ends when the response is destroyed without an error (res.destroy()) · Issue #25469 · getsentry/sentry-javascript

X Title: node:http client span never ends when the response is destroyed without an error (res.destroy()) · Issue #25469 · getsentry/sentry-javascript

Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using the latest SDK release https://github.com/...

Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...

X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...

Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/25469

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"node:http client span never ends when the response is destroyed without an error (res.destroy())","articleBody":"\n### Is there an existing issue for this?\n\n- [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\n- [x] I have reviewed the documentation https://docs.sentry.io/\n- [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\n\n### How do you use Sentry?\n\nSentry SaaS (sentry.io)\n\n### Which SDK are you using?\n\n@sentry/node\n\n### SDK Version\n\n11.8.0 (latest at the time of writing)\n\n### Framework Version\n\nNode v25.8.0, plain `node:http`, no framework\n\n### Link to Sentry event\n\nn/a, local repro (the DSN points at a local sink on 127.0.0.1)\n\n### Reproduction Example/SDK Setup\n\nSelf-contained, only needs `npm i @sentry/node`. It starts a local server that sends headers and\nthen streams a body, and a local DSN sink that collects the envelopes.\n\n```js\n// Repro: http.client span is never ended when the response is destroyed mid-body.\n// Usage: npm i @sentry/node && node nodehttp-repro.mjs\n// Everything is local (127.0.0.1); no real DSN is used.\nimport * as Sentry from '@sentry/node';\nimport http from 'node:http';\n\n// Local DSN sink: collects envelopes so we can see which spans were actually sent.\nconst sentSpans = new Map(); // url.full -> status, for http.client spans that reached the sink\nconst collect = o => {\n  if (!o || typeof o !== 'object') return;\n  const a = o.attributes || {};\n  const url = a['url.full']?.value ?? a['url.full'] ?? o.data?.['url.full'];\n  const op = a['sentry.op']?.value ?? a['sentry.op'] ?? o.op;\n  if (op === 'http.client' && url) sentSpans.set(url, o.status);\n  for (const v of Object.values(o)) if (v && typeof v === 'object') collect(v);\n};\nconst sink = http.createServer((req, res) => {\n  let body = '';\n  req.on('data', c => (body += c));\n  req.on('end', () => {\n    for (const line of body.split('\\n')) { try { collect(JSON.parse(line)); } catch {} }\n    res.end('{}');\n  });\n});\nawait new Promise(r => sink.listen(0, '127.0.0.1', r));\n\nSentry.init({\n  dsn: `http://k@127.0.0.1:${sink.address().port}/1`,\n  tracesSampleRate: 1,\n  // do not trace the sink itself\n  ignoreOutgoingRequests: url => url.includes(`:${sink.address().port}`),\n});\n\nconst ended = new Map(); // url.full -> status\nSentry.getClient().on('spanEnd', span => {\n  const j = Sentry.spanToJSON(span);\n  const url = j.attributes?.['url.full'] ?? j.data?.['url.full'];\n  const op = j.attributes?.['sentry.op'] ?? j.op;\n  if (op === 'http.client' && url) ended.set(url, j.status);\n});\n\n// Server that streams a slow body (headers sent, body never finishes on its own).\nconst srv = http.createServer((req, res) => {\n  res.writeHead(200);\n  res.write('first chunk');\n  if (req.url.startsWith('/full')) setTimeout(() => res.end('rest'), 50);\n});\nawait new Promise(r => srv.listen(0, '127.0.0.1', r));\nconst port = srv.address().port;\n\nconst cases = {\n  full: res => { res.on('data', () => {}); },\n  'res.destroy()': res => { res.once('data', () => res.destroy()); },\n  'res.destroy(new Error())': res => { res.once('data', () => res.destroy(new Error('boom'))); },\n};\n\nawait Sentry.startSpan({ name: 'root' }, async () => {\n  for (const [name, handle] of Object.entries(cases)) {\n    await new Promise(resolve => {\n      const path = `/${name === 'full' ? 'full' : 'slow'}?case=${encodeURIComponent(name)}`;\n      const req = http.get({ host: '127.0.0.1', port, path }, res => {\n        handle(res);\n        res.on('close', () => setTimeout(resolve, 300));\n        res.on('error', () => {});\n      });\n      req.on('error', () => {});\n    });\n  }\n});\n\nawait Sentry.flush(2000);\nfor (const name of Object.keys(cases)) {\n  const path = `/${name === 'full' ? 'full' : 'slow'}?case=${encodeURIComponent(name)}`;\n  const url = `http://127.0.0.1:${port}${path}`;\n  console.log(\n    name.padEnd(26),\n    '| spanEnd fired:', ended.has(url) ? `yes (status=${ended.get(url)})` : 'NO',\n    '| span in envelope:', sentSpans.has(url) ? `yes (status=${sentSpans.get(url)})` : 'NO',\n  );\n}\nsrv.closeAllConnections();\nsrv.close();\nsink.close();\nsetTimeout(() => process.exit(0), 100);\n```\n\n### Steps to Reproduce\n\n1. `npm i @sentry/node@11.8.0`\n2. Save the script above as `repro.mjs` and run `node repro.mjs`.\n3. Look at the three `http.client` spans: one for a fully read response, one where the client calls\n   `res.destroy()` after the first chunk, and one where it calls `res.destroy(new Error('boom'))`.\n\n### Expected Result\n\nAll three `http.client` spans end. A response that was cut off before the end should end the span\nwith an error status (the code already does this for an aborted response, see `response.aborted`\nin `finishWithResponse`).\n\n### Actual Result\n\n```\nfull                       | spanEnd fired: yes (status=ok) | span in envelope: yes (status=ok)\nres.destroy()              | spanEnd fired: NO | span in envelope: NO\nres.destroy(new Error())   | spanEnd fired: yes (status=error) | span in envelope: yes (status=error)\n```\n\nWith `res.destroy()` the span never ends, so it is never sent.\n\nI also checked the other ways to cut a request short after the response headers arrived. These\nall end the span correctly: `req.destroy()` (error), `req.destroy(new Error())` (error),\n`AbortController.abort()` on `http.request` after the headers (ok, per #25260), and abort before\nthe response (ok).\n\n### Additional Context\n\nCause, in `packages/core/src/integrations/http/client-subscriptions.ts` on `develop`:\n\n- L143: the request `close` fallback (`requestOnClose`) is what ends the span if there is no response.\n- L168: as soon as a response arrives, that fallback is removed (`request.removeListener('close', requestOnClose)`),\n  because the span should now end with the response.\n- L197-198: the only things that can end it after that are `response.on('end', ...)` and\n  `response.on(errorMonitor, ...)`.\n\n`res.destroy()` without an argument emits neither `end` nor `error` on the response, only `close`\n(and `aborted`). So nothing is left that ends the span. With `res.destroy(err)` the response emits\n`error`, which is why that case works. The `aborted` check at L187 is only reached through those\ntwo listeners, so it never sees this case.\n\nThis is the same kind of gap that #25260 (http client, abort is not an error) and #25129 (fetch) fixed\nfor aborts by the caller, but those only change the status of spans that already end. I could not find\nan existing issue or PR for the span not ending at all. I searched open and closed issues and PRs for\nhttp client span, destroy, aborted and leak. The closest are #25183 and #25209, which are the same\nsymptom for the Express request-handler span.\n\nA fix would be to also end the span on the response `close` event (a no-op if `end` or `error` already\nfired), with an error status when the response is incomplete. I have a patch with tests and can open a PR\nif that direction is fine.\n","author":{"url":"https://github.com/4ktLuffy","@type":"Person","name":"4ktLuffy"},"datePublished":"2026-10-16T20:48:00Z","url":"https://github.com/getsentry/sentry-javascript/issues/25469"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:d27dd2d6-6025-be4b-3dca-a73e90cdb2a5
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id97FE:237D74:43AD2:5AFC2:6B042A8E
html-safe-nonce2b9a89fb82017a62b217c224fd013bbb42e8ed0065bf0ac5d02ef4c49f3b9d0d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5N0ZFOjIzN0Q3NDo0M0FEMjo1QUZDMjo2QjA0MkE4RSIsInZpc2l0b3JfaWQiOiI0NjE4NTc5NDM0MTQyOTY4NDYyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac96419361b1b0e2fd24c6159ae32afd533a0370d32d734a33d0949dede45bd386
hovercard-subject-tagissue:5890975551
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/25469/issue_layout
twitter:imagehttps://opengraph.githubassets.com/82a68577b4dabe273a2e465c749f07ce55e13b80d28f28a77b0c640469b9a34d/getsentry/sentry-javascript/issues/25469
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/82a68577b4dabe273a2e465c749f07ce55e13b80d28f28a77b0c640469b9a34d/getsentry/sentry-javascript/issues/25469
og:image:altIs there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:username4ktLuffy
hostnamegithub.com
expected-hostnamegithub.com
Noneb7a1d2b9101496921b08579fbee988d014345aef2f5bd660d1f8c7332d81560e
turbo-cache-controlno-preview
go-importgithub.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git
octolytics-dimension-user_id1396951
octolytics-dimension-user_logingetsentry
octolytics-dimension-repository_id3328572
octolytics-dimension-repository_nwogetsentry/sentry-javascript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id3328572
octolytics-dimension-repository_network_root_nwogetsentry/sentry-javascript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasec3dd496c3da6ea6b77e69c09279d2b81604654f1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/getsentry/sentry-javascript/issues/25469#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-javascript%2Fissues%2F25469
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-javascript%2Fissues%2F25469
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=getsentry%2Fsentry-javascript
Reloadhttps://github.com/getsentry/sentry-javascript/issues/25469
Reloadhttps://github.com/getsentry/sentry-javascript/issues/25469
Reloadhttps://github.com/getsentry/sentry-javascript/issues/25469
getsentryhttps://github.com/getsentry
sentry-javascripthttps://github.com/getsentry/sentry-javascript
Codehttps://github.com/getsentry/sentry-javascript
Issues341 (341)https://github.com/getsentry/sentry-javascript/issues
Pull requests58 (58)https://github.com/getsentry/sentry-javascript/pulls
Discussionshttps://github.com/getsentry/sentry-javascript/discussions
Actionshttps://github.com/getsentry/sentry-javascript/actions
Security and quality7 (7)https://github.com/getsentry/sentry-javascript/security
Insightshttps://github.com/getsentry/sentry-javascript/insights
https://github.com/getsentry/sentry-javascript
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-javascript/issues/25469
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-javascript/issues/25469
#25503https://github.com/getsentry/sentry-javascript/pull/25503
node:http client span never ends when the response is destroyed without an error (res.destroy())https://github.com/getsentry/sentry-javascript/issues/25469#top
#25503https://github.com/getsentry/sentry-javascript/pull/25503
Bughttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Bug%22
Node.jshttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Node.js%22
https://github.com/4ktLuffy
4ktLuffyhttps://github.com/4ktLuffy
on Oct 16, 2026https://github.com/getsentry/sentry-javascript/issues/25469#issue-5890975551
https://github.com/getsentry/sentry-javascript/issueshttps://github.com/getsentry/sentry-javascript/issues
https://docs.sentry.io/https://docs.sentry.io/
https://github.com/getsentry/sentry-javascript/releaseshttps://github.com/getsentry/sentry-javascript/releases
#25260https://github.com/getsentry/sentry-javascript/pull/25260
#25260https://github.com/getsentry/sentry-javascript/pull/25260
#25129https://github.com/getsentry/sentry-javascript/pull/25129
#25183https://github.com/getsentry/sentry-javascript/issues/25183
#25209https://github.com/getsentry/sentry-javascript/pull/25209
getsantryhttps://github.com/apps/getsantry
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
on Oct 16, 2026https://github.com/getsentry/sentry-javascript/issues/25469#event-33482357763
https://github.com/apps/linear-code
linear-codehttps://github.com/apps/linear-code
on Oct 16, 2026https://github.com/getsentry/sentry-javascript/issues/25469#issuecomment-6224405213
Linear Codehttps://linear.app
JS-3950https://linear.app/getsentry/issue/JS-3950
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
on Oct 16, 2026https://github.com/getsentry/sentry-javascript/issues/25469#event-33513247402
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
on Oct 16, 2026https://github.com/getsentry/sentry-javascript/issues/25469
github-actionshttps://github.com/apps/github-actions
Node.jshttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Node.js%22
on Oct 16, 2026https://github.com/getsentry/sentry-javascript/issues/25469#event-33482364910
linear-codehttps://github.com/apps/linear-code
Bughttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Bug%22
on Oct 16, 2026https://github.com/getsentry/sentry-javascript/issues/25469#event-33482399233
https://github.com/s1gr1d
s1gr1dhttps://github.com/s1gr1d
on Oct 19, 2026https://github.com/getsentry/sentry-javascript/issues/25469#issuecomment-6263261916
getsantryhttps://github.com/apps/getsantry
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
on Oct 19, 2026https://github.com/getsentry/sentry-javascript/issues/25469#event-33625745447
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
on Oct 19, 2026https://github.com/getsentry/sentry-javascript/issues/25469
isaacshttps://github.com/isaacs
completedhttps://github.com/getsentry/sentry-javascript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#25503https://github.com/getsentry/sentry-javascript/pull/25503
on Oct 27, 2026https://github.com/getsentry/sentry-javascript/issues/25469#event-34417294997
lfantonehttps://github.com/lfantone
on Oct 27, 2026https://github.com/getsentry/sentry-javascript/issues/25469#event-34418738263
fix(core): End node:http client spans when the response is destroyed (g…https://github.com/lfantone/sentry-javascript/commit/f8b8d4068c6a7e75389b9f2a28563bad664d93ed
g…https://github.com/getsentry/sentry-javascript/pull/25503
https://docs.github.com/articles/closing-issues-via-commit-messages
f8b8d40https://github.com/lfantone/sentry-javascript/commit/f8b8d4068c6a7e75389b9f2a28563bad664d93ed
https://github.com/apps/github-actions
github-actionshttps://github.com/apps/github-actions
on Oct 28, 2026https://github.com/getsentry/sentry-javascript/issues/25469#issuecomment-6474400075
GitHub Actionshttps://help.github.com/en/actions
#25503https://github.com/getsentry/sentry-javascript/pull/25503
11.10.0 releasehttps://github.com/getsentry/sentry-javascript/releases/tag/11.10.0
Sign up for freehttps://github.com/signup?return_to=https://github.com/getsentry/sentry-javascript/issues/25469
Sign in to commenthttps://github.com/login?return_to=https://github.com/getsentry/sentry-javascript/issues/25469
Bughttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Bug%22
Node.jshttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Node.js%22
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.