Skip to content

fix(net): clean up synchronous connection failures - #10128

Merged
BridgeAR merged 2 commits into
masterfrom
BridgeAR/2026-09-03-net-connect-sync-cleanup
Sep 3, 2026
Merged

BridgeAR merged 2 commits into
masterfrom
BridgeAR/2026-09-03-net-connect-sync-cleanup

Conversation

@BridgeAR

@BridgeAR BridgeAR commented Sep 3, 2026

Copy link
Copy Markdown
Member

Node.js validates some TCP and IPC connection options synchronously before a socket emits any lifecycle event. Those failures bypassed tracer cleanup and retained listeners plus a nested emit wrapper on every retry.

Clean up only the current attempt before rethrowing the original error, and leave caller-owned listeners, callback identity, and the previous emit implementation unchanged.

Node.js validates some TCP and IPC connection options synchronously before a socket emits any lifecycle event. Those failures bypassed tracer cleanup and retained listeners plus a nested emit wrapper on every retry.

Clean up only the current attempt before rethrowing the original error, and leave caller-owned listeners, callback identity, and the previous emit implementation unchanged.
@dd-octo-sts

dd-octo-sts Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 8.74 MB
Deduped: 9.41 MB
No deduping: 9.41 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.4.0 | 127.33 kB | 447.04 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 Sep 3, 2026 •

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 98.63% (-0.01%)

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

@codecov

codecov Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.62%. Comparing base (6e65a91) to head (eebbe00).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10128      +/-   ##
==========================================
- Coverage   98.63%   98.62%   -0.01%     
==========================================
  Files        1002     1002              
  Lines      154897   154894       -3     
  Branches    13358    13358              
==========================================
- Hits       152779   152765      -14     
- Misses       2118     2129      +11     
Flag Coverage Δ
aiguard 63.83% <92.85%> (-0.03%) ⬇️
aiguard-integration 58.94% <57.14%> (-0.01%) ⬇️
apm-capabilities-tracing 62.85% <100.00%> (+<0.01%) ⬆️
apm-integrations-aerospike 61.24% <92.85%> (-0.03%) ⬇️
apm-integrations-aerospike-_integrat-1d185c06 63.21% <100.00%> (-0.03%) ⬇️
apm-integrations-confluentinc-kafka--d0bf0045 67.28% <100.00%> (-0.06%) ⬇️
apm-integrations-couchbase 61.74% <100.00%> (-0.03%) ⬇️
apm-integrations-elasticsearch_integ-31b69669 68.57% <100.00%> (-0.02%) ⬇️
apm-integrations-http 66.85% <92.85%> (-0.02%) ⬇️
apm-integrations-http2_integrations--9aea12f5 68.17% <100.00%> (-0.03%) ⬇️
apm-integrations-kafkajs 67.89% <100.00%> (-0.03%) ⬇️
apm-integrations-next 64.90% <100.00%> (-0.03%) ⬇️
apm-integrations-prisma 62.50% <100.00%> (-0.02%) ⬇️
apm-integrations-restify_integration-b312dd16 ?
apm-integrations-restify_integrations-sharedb 63.89% <100.00%> (?)
appsec 77.31% <92.85%> (-0.02%) ⬇️
appsec-express_fastify_graphql 72.70% <92.85%> (-0.02%) ⬇️
appsec-integration 49.54% <64.28%> (-0.01%) ⬇️
appsec-kafka_ldapjs_lodash 67.98% <92.85%> (-0.02%) ⬇️
appsec-mongodb-core_mongoose_mysql 71.12% <92.85%> (-0.02%) ⬇️
appsec-next 57.69% <100.00%> (-0.02%) ⬇️
appsec-node-serialize_passport_postgres 70.61% <92.85%> (-0.02%) ⬇️
appsec-sourcing_stripe_template 69.06% <92.85%> (-0.02%) ⬇️
debugger 69.76% <100.00%> (-0.02%) ⬇️
instr-ai_instrumentation-anthropic-l-e862da55 56.60% <92.85%> (-0.03%) ⬇️
instr-bluebird_instrumentation-body--02ae4b41 64.84% <92.85%> (-0.03%) ⬇️
instr-confluentinc-kafka-javascript 56.01% <92.85%> (-0.03%) ⬇️
instr-connect_instrumentation-cookie-0bbb44d9 57.71% <92.85%> (-0.03%) ⬇️
instr-couchbase 55.22% <92.85%> (-0.03%) ⬇️
instr-cypress-config_instrumentation-4db1de46 58.02% <92.85%> (-0.03%) ⬇️
instr-express-multi-version_instrume-f5caf487 64.31% <92.85%> (-0.03%) ⬇️
instr-fetch_instrumentation-fs_instr-43dfe6a2 50.55% <92.85%> (-0.02%) ⬇️
instr-hono_instrumentation-http_inst-026a5d4d 66.17% <92.85%> (-0.03%) ⬇️
instr-kafkajs_instrumentation-knex_i-ca6f5b19 56.66% <92.85%> (-0.03%) ⬇️
instr-light-my-request_instrumentati-8c9fceca 63.61% <92.85%> (-0.03%) ⬇️
instr-mysql_instrumentation-mysql2_i-05f94c42 59.11% <92.85%> (-0.02%) ⬇️
instr-openai-lifecycle_instrumentati-783580bd 65.97% <92.85%> (-0.02%) ⬇️
instr-passport-http_instrumentation--2b6c8eb6 66.58% <92.85%> (-0.02%) ⬇️
instr-promise_instrumentation-promis-8479bae3 56.44% <92.85%> (-0.03%) ⬇️
instr-restify_instrumentation-router-5641467c 56.58% <92.85%> (-0.03%) ⬇️
instr-url_instrumentation-when_instr-22ca7078 56.47% <92.85%> (-0.03%) ⬇️
instrumentations-integration-esbuild 34.68% <0.00%> (+<0.01%) ⬆️
llmobs-ai_anthropic_bedrock 66.83% <100.00%> (-0.03%) ⬇️
llmobs-claude-agent-sdk_google-genai-da2c851e 64.99% <100.00%> (-0.02%) ⬇️
llmobs-openai 66.81% <100.00%> (-0.02%) ⬇️
llmobs-openai-agents_vertex-ai 64.13% <100.00%> (-0.04%) ⬇️
llmobs-sdk 76.58% <92.85%> (-0.03%) ⬇️
master-coverage 98.62% <100.00%> (?)
openfeature 60.12% <57.14%> (-0.01%) ⬇️
openfeature-unit 58.85% <92.85%> (-0.03%) ⬇️
platform-core_esbuild_instrumentations-misc 41.35% <92.85%> (-0.02%) ⬇️
platform-integration 65.22% <64.28%> (-0.01%) ⬇️
platform-shimmer_unit-guardrails_webpack 39.10% <92.85%> (-0.02%) ⬇️
plugins-aws-durable-execution-sdk-js-2bc88c07 61.13% <100.00%> (-0.02%) ⬇️
plugins-azure-event-hubs_azure-servi-50d5b0fc 58.53% <57.14%> (-0.01%) ⬇️
plugins-browser-bunyan_bullmq_cassandra 66.37% <100.00%> (-0.03%) ⬇️
plugins-cookie_cookie-parser_crypto 56.21% <92.85%> (-0.03%) ⬇️
plugins-dd-trace-api_express-mongo-s-83827a5c 61.80% <92.85%> (-0.03%) ⬇️
plugins-fastify_fetch_fs 65.98% <100.00%> (-0.02%) ⬇️
plugins-generic-pool_google-cloud-pubsub_grpc 69.55% <100.00%> (-0.02%) ⬇️
plugins-handlebars_hapi_hono 64.28% <92.85%> (-0.03%) ⬇️
plugins-ioredis_knex_langgraph 61.98% <100.00%> (-0.03%) ⬇️
plugins-ldapjs_light-my-request_limitd-client 63.99% <100.00%> (-0.03%) ⬇️
plugins-lodash_mariadb_memcached 64.46% <100.00%> (-0.03%) ⬇️
plugins-mercurius_microgateway-core_-b9bd83c4 67.84% <100.00%> (-0.02%) ⬇️
plugins-moleculer_mongodb_mongodb-core 66.72% <100.00%> (-0.03%) ⬇️
plugins-mongoose_multer_mysql 64.57% <100.00%> (-0.03%) ⬇️
plugins-mysql2_nats_node-serialize 66.80% <100.00%> (-0.03%) ⬇️
plugins-opensearch_passport-http_pino 64.70% <100.00%> (-0.03%) ⬇️
plugins-postgres_process_pug 63.75% <100.00%> (-0.03%) ⬇️
plugins-redis_router_sequelize 67.28% <100.00%> (-0.03%) ⬇️
plugins-test-and-upstream-amqp10_tes-914101e2 65.50% <100.00%> (-0.02%) ⬇️
plugins-test-and-upstream-avsc_test--408e8d3a 65.62% <100.00%> (-0.03%) ⬇️
plugins-test-and-upstream-graphql_te-59dd94de 68.85% <100.00%> (-0.02%) ⬇️
plugins-test-and-upstream-rhea_undici_url 66.60% <100.00%> (-0.03%) ⬇️
plugins-valkey_vm_winston 63.03% <100.00%> (-0.07%) ⬇️
plugins-ws 65.13% <92.85%> (-0.03%) ⬇️
profiling 66.69% <100.00%> (-0.02%) ⬇️
serverless-aws-sdk-aws-sdk 55.96% <92.85%> (-0.02%) ⬇️
serverless-aws-sdk-base-inject-field 55.78% <92.85%> (-0.03%) ⬇️
serverless-aws-sdk-bedrockruntime 59.31% <92.85%> (-0.02%) ⬇️
serverless-aws-sdk-client 60.68% <100.00%> (-0.03%) ⬇️
serverless-aws-sdk-dynamodb 59.76% <92.85%> (-0.02%) ⬇️
serverless-aws-sdk-eventbridge 58.14% <92.85%> (-0.02%) ⬇️
serverless-aws-sdk-kinesis 63.69% <92.85%> (-0.02%) ⬇️
serverless-aws-sdk-lambda 61.68% <92.85%> (-0.02%) ⬇️
serverless-aws-sdk-s3 59.79% <92.85%> (-0.02%) ⬇️
serverless-aws-sdk-serverless-peer-service 64.25% <92.85%> (-0.02%) ⬇️
serverless-aws-sdk-sns 64.58% <92.85%> (-0.02%) ⬇️
serverless-aws-sdk-sqs 65.04% <100.00%> (-0.02%) ⬇️
serverless-aws-sdk-stepfunctions 59.66% <92.85%> (-0.02%) ⬇️
serverless-aws-sdk-util 56.40% <92.85%> (-0.03%) ⬇️
serverless-azure-durable-functions_a-776237ee 57.68% <57.14%> (-0.01%) ⬇️
serverless-azure-functions-eventhubs-61ee6313 64.33% <92.85%> (-0.03%) ⬇️
test-optimization-cucumber 70.41% <100.00%> (+0.01%) ⬆️
test-optimization-cypress 64.81% <64.28%> (-0.13%) ⬇️
test-optimization-jest 71.90% <100.00%> (+0.01%) ⬆️
test-optimization-mocha 71.90% <100.00%> (+0.05%) ⬆️
test-optimization-playwright-playwri-363e40a6 59.70% <64.28%> (+0.10%) ⬆️
test-optimization-playwright-playwri-5141d36d 61.22% <64.28%> (-0.03%) ⬇️
test-optimization-playwright-playwri-5b35813b 59.59% <64.28%> (-0.03%) ⬇️
test-optimization-playwright-playwri-924f4516 60.87% <64.28%> (-0.03%) ⬇️
test-optimization-playwright-playwri-d6f5a99b 59.47% <64.28%> (+0.02%) ⬆️
test-optimization-playwright-playwright-atr 59.20% <64.28%> (-0.03%) ⬇️
test-optimization-playwright-playwright-efd 60.12% <64.28%> (-0.03%) ⬇️
test-optimization-selenium 58.78% <64.28%> (-0.07%) ⬇️
test-optimization-testopt 61.45% <100.00%> (+0.02%) ⬆️
test-optimization-vitest 72.48% <100.00%> (+0.08%) ⬆️
test-optimization-vitest-browser 58.85% <64.28%> (+0.49%) ⬆️
test-optimization-webdriverio 65.88% <100.00%> (+0.04%) ⬆️

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 Sep 3, 2026 •

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-09-03 15:14:30

Comparing candidate commit eebbe00 in PR branch BridgeAR/2026-09-03-net-connect-sync-cleanup with baseline commit 6e65a91 in branch master.

📊 Benchmarking dashboard

Found 3 performance improvements and 0 performance regressions! Performance is the same for 2307 metrics, 18 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 ----------------------------------'

scenario:net-with-tracer-26

  • 🟩 execution_time [-87.576ms; -46.127ms] or [-10.170%; -5.357%]
  • 🟩 instructions [-90.3M instructions; -45.2M instructions] or [-6.791%; -3.399%]

scenario:plugin-http-client-with-tracer-26

  • 🟩 execution_time [-212.536ms; -70.977ms] or [-7.366%; -2.460%]

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-24

  • unstable max_rss_usage [-28.951MB; +46.046MB] or [-10.194%; +16.213%]

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

  • unstable max_rss_usage [-17.527MB; +22.795MB] or [-7.692%; +10.004%]

scenario:appsec-iast-no-vulnerability-iast-enabled-default-config-24

  • unstable max_rss_usage [-22.996MB; +31.015MB] or [-7.066%; +9.530%]

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

  • unstable max_rss_usage [-28.006MB; +15.699MB] or [-7.219%; +4.047%]

scenario:debugger-line-probe-without-snapshot-24

  • unstable max_rss_usage [-8.891MB; +21.919MB] or [-3.048%; +7.514%]

scenario:debugger-line-probe-without-snapshot-26

  • unstable max_rss_usage [-13.374MB; +21.318MB] or [-4.972%; +7.925%]

scenario:dogstatsd-with-tags-20

  • unstable cpu_user_time [-508.109ms; +233.151ms] or [-10.024%; +4.599%]
  • unstable execution_time [-514.413ms; +238.469ms] or [-9.993%; +4.632%]
  • unstable throughput [-79247.445op/s; +174197.493op/s] or [-4.857%; +10.677%]

scenario:encoders-0.4-immediate-flush-20

  • unstable max_rss_usage [-6.294MB; +9.105MB] or [-8.656%; +12.520%]

scenario:id-parse-128bit-20

  • unstable execution_time [-135.700ms; +198.480ms] or [-5.013%; +7.332%]

scenario:llmobs-encode-unicode-mixed-20

  • unstable max_rss_usage [-13.216MB; +3.140MB] or [-17.656%; +4.194%]

scenario:plugin-claude-agent-sdk-compact-stream-scan-26

  • unstable cpu_usage_percentage [-7.603%; +3.973%]

scenario:plugin-graphql-long-with-depth-off-20

  • unstable max_rss_usage [-5358.959KB; +7226.387KB] or [-4.312%; +5.814%]

scenario:plugin-memcached-hashring-24

  • unstable execution_time [-146.232ms; +143.370ms] or [-5.638%; +5.527%]

scenario:plugin-mongodb-core-binary-hash-26

  • unstable execution_time [-127.217ms; +157.068ms] or [-6.152%; +7.596%]
  • unstable throughput [-120762.916op/s; +107618.138op/s] or [-5.508%; +4.908%]

scenario:test-optimization-large-suite-20

  • unstable max_rss_usage [-4284.952KB; +5860.952KB] or [-5.352%; +7.320%]

The restoration assignment owns no state or lifecycle, so keeping it in a helper obscured the existing connection branches. Inline the assignment at each branch while preserving the accepted own-property contract.
@BridgeAR
BridgeAR marked this pull request as ready for review September 3, 2026 15:02
@BridgeAR
BridgeAR requested review from a team as code owners September 3, 2026 15:02
@BridgeAR
BridgeAR requested a review from tlhunter September 3, 2026 15:02
@BridgeAR
BridgeAR enabled auto-merge (squash) September 3, 2026 16:25
@BridgeAR
BridgeAR disabled auto-merge September 3, 2026 19:54
@BridgeAR
BridgeAR merged commit 5809647 into master Sep 3, 2026
758 of 759 checks passed
@BridgeAR
BridgeAR deleted the BridgeAR/2026-09-03-net-connect-sync-cleanup branch September 3, 2026 19:54
dd-octo-sts Bot pushed a commit that referenced this pull request Sep 3, 2026
* fix(net): clean up synchronous connection failures

Node.js validates some TCP and IPC connection options synchronously before a socket emits any lifecycle event. Those failures bypassed tracer cleanup and retained listeners plus a nested emit wrapper on every retry.

Clean up only the current attempt before rethrowing the original error, and leave caller-owned listeners, callback identity, and the previous emit implementation unchanged.

* refactor(net): inline socket emit restoration

The restoration assignment owns no state or lifecycle, so keeping it in a helper obscured the existing connection branches. Inline the assignment at each branch while preserving the accepted own-property contract.
This was referenced Sep 3, 2026
dd-octo-sts Bot pushed a commit that referenced this pull request Sep 3, 2026
* fix(net): clean up synchronous connection failures

Node.js validates some TCP and IPC connection options synchronously before a socket emits any lifecycle event. Those failures bypassed tracer cleanup and retained listeners plus a nested emit wrapper on every retry.

Clean up only the current attempt before rethrowing the original error, and leave caller-owned listeners, callback identity, and the previous emit implementation unchanged.

* refactor(net): inline socket emit restoration

The restoration assignment owns no state or lifecycle, so keeping it in a helper obscured the existing connection branches. Inline the assignment at each branch while preserving the accepted own-property contract.
BridgeAR added a commit that referenced this pull request Sep 4, 2026
* fix(net): clean up synchronous connection failures

Node.js validates some TCP and IPC connection options synchronously before a socket emits any lifecycle event. Those failures bypassed tracer cleanup and retained listeners plus a nested emit wrapper on every retry.

Clean up only the current attempt before rethrowing the original error, and leave caller-owned listeners, callback identity, and the previous emit implementation unchanged.

* refactor(net): inline socket emit restoration

The restoration assignment owns no state or lifecycle, so keeping it in a helper obscured the existing connection branches. Inline the assignment at each branch while preserving the accepted own-property contract.
BridgeAR added a commit that referenced this pull request Sep 4, 2026
* fix(net): clean up synchronous connection failures

Node.js validates some TCP and IPC connection options synchronously before a socket emits any lifecycle event. Those failures bypassed tracer cleanup and retained listeners plus a nested emit wrapper on every retry.

Clean up only the current attempt before rethrowing the original error, and leave caller-owned listeners, callback identity, and the previous emit implementation unchanged.

* refactor(net): inline socket emit restoration

The restoration assignment owns no state or lifecycle, so keeping it in a helper obscured the existing connection branches. Inline the assignment at each branch while preserving the accepted own-property contract.
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.

2 participants