Skip to content

fix(http): keep client spans open after socket timeouts - #11352

Open
BridgeAR wants to merge 3 commits into
masterfrom
BridgeAR/2026-11-20-issue-11331-http-terminal
Open

BridgeAR wants to merge 3 commits into
masterfrom
BridgeAR/2026-11-20-issue-11331-http-terminal

Conversation

@BridgeAR

@BridgeAR BridgeAR commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

A socket idle timeout does not end a Node.js HTTP request. Finishing the span then can lose the status, undercount the duration, or hide a later cancellation error.

Finish the span on a terminal event and record the stream error if the response is interrupted. A request that succeeds after a configured timeout no longer counts as an error. Remove the AppSec close listener that compensated for the early finish.

Fixes #11331

This requires System Test fixes to land.

@dd-octo-sts

dd-octo-sts Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 9.56 MB
Deduped: 10.31 MB
No deduping: 10.31 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.5.3 | 131.25 kB | 531.9 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 6 Pipeline jobs failed

AppSec | AppSec / integration (node-active) — 🔧 Needs a code fix, caused by this PR

View more details · View in GitHub Actions

AppSec | AppSec / integration (node-latest) — 🔧 Needs a code fix, caused by this PR

View more details · View in GitHub Actions

AppSec | AppSec / integration (node-oldest) — 🔧 Needs a code fix, caused by this PR

View more details · View in GitHub Actions

View all 6 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 73.53%
• Overall Coverage: 86.02% (-3.56%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 5235a36 | Docs | View more details | Give us feedback!

@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.52941% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.07%. Comparing base (41dee42) to head (5235a36).

Files with missing lines Patch % Lines
packages/dd-trace/src/appsec/reporter.js 14.28% 6 Missing ⚠️
packages/dd-trace/src/span_processor.js 75.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11352      +/-   ##
==========================================
- Coverage   89.61%   86.07%   -3.54%     
==========================================
  Files        1128     1127       -1     
  Lines      184036   183966      -70     
  Branches       86       73      -13     
==========================================
- Hits       164923   158348    -6575     
- Misses      19113    25618    +6505     
Flag Coverage Δ
ai-guard 63.32% <42.42%> (-0.03%) ⬇️
apm-capabilities 55.17% <70.58%> (+<0.01%) ⬆️
apm-integrations 81.95% <73.52%> (-0.02%) ⬇️
appsec ?
debugger 70.88% <57.57%> (-0.02%) ⬇️
instrumentation 60.17% <73.52%> (+0.04%) ⬆️
llmobs 82.51% <69.69%> (-0.02%) ⬇️
master-coverage 86.07% <73.52%> (?)
openfeature 68.06% <42.42%> (-0.03%) ⬇️
platform 68.14% <45.45%> (-0.02%) ⬇️
profiling 66.51% <57.57%> (-0.02%) ⬇️
serverless 66.66% <72.72%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pr-commenter

pr-commenter Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-11-23 19:21:01

Comparing candidate commit 5235a36 in PR branch BridgeAR/2026-11-20-issue-11331-http-terminal with baseline commit 41dee42 in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 2476 metrics, 11 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:appsec-appsec-enabled-20

  • unstable max_rss_usage [-21.960MB; +93.198MB] or [-8.802%; +37.356%]

scenario:appsec-iast-with-vulnerability-iast-enabled-default-config-20

  • unstable max_rss_usage [-55.649MB; +50.553MB] or [-15.233%; +13.838%]

scenario:openfeature-initialization-configuration-20

  • unstable max_rss_usage [-5674.252KB; +5686.980KB] or [-7.344%; +7.360%]

scenario:openfeature-initialization-configuration-26

  • unstable cpu_user_time [-110.554ms; +118.997ms] or [-6.472%; +6.966%]
  • unstable execution_time [-108.722ms; +121.773ms] or [-6.134%; +6.870%]
  • unstable throughput [-37856.616op/s; +33286.337op/s] or [-6.585%; +5.790%]

scenario:openfeature-initialization-error-20

  • unstable max_rss_usage [-3.653MB; +6.645MB] or [-4.854%; +8.830%]

scenario:openfeature-initialization-error-26

  • unstable cpu_user_time [-92.578ms; +189.858ms] or [-3.526%; +7.231%]
  • unstable execution_time [-91.982ms; +188.117ms] or [-3.421%; +6.996%]
  • unstable throughput [-25344.052op/s; +12713.086op/s] or [-6.735%; +3.379%]

scenario:openfeature-scale-full-26

  • unstable max_rss_usage [-38.321MB; +26.850MB] or [-17.194%; +12.048%]

@BridgeAR
BridgeAR marked this pull request as ready for review November 20, 2026 18:10
@BridgeAR
BridgeAR requested review from a team as code owners November 20, 2026 18:10
@BridgeAR
BridgeAR requested review from wconti27 and removed request for a team November 20, 2026 18:10
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T19:12:17.256593Z 5235a36 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@CarlesDD

CarlesDD commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

One case to consider: if the app has a response cb but never reads the body, Node.js never emits end. With this change, the span (and the whole trace), only finishes when the remote closes de idle socket. Today the default's agent's 5s timeout caps it. (repro with this branch vs its base: against nginx with its default config, the span takes 65 s and the trace reaches the agent at 68 s (base: 5 s / 7 s); against a Go server with defaults, it never arrives)

I know it's an app bug, but those traces, including Appsec events would arrive late or never. Is that an acceptable trade-off or worth keeping some bound?

Node can emit a socket idle timeout without ending the request. Finishing the span then can lose the status, undercount the duration, or hide a later cancellation error.

After a partial response, Node can report the interruption on the response stream instead of the request. Capture that error at finish without replacing a request error or ending response inspection early.

Fixes: #11331
Node emits abort before it records the error for an interrupted HTTP
request or response. Finishing a socket-backed request at abort can
report the interrupted operation as successful. A request without a
socket still needs to finish at abort because it can wait for a slot
in the socket pool before it emits close.

Refs: #11331
An unread outbound response can keep a client span open after the
server request ends. Waiting for the full trace can keep a recorded
AppSec finding buffered until that unrelated response closes.
@BridgeAR
BridgeAR force-pushed the BridgeAR/2026-11-20-issue-11331-http-terminal branch from d541ad9 to 5235a36 Compare November 23, 2026 19:10
@BridgeAR
BridgeAR requested a review from a team as a code owner November 23, 2026 19:10
@BridgeAR
BridgeAR requested review from pabloerhard and removed request for a team November 23, 2026 19:10

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: http client span finishes at the default agent's 5 s socket 'timeout' while the request carries on

2 participants