Skip to content

fix(test-optimization): retry payload delivery failures - #10069

Merged
juan-fernandez merged 3 commits into
juan-fernandez/test-optimization-delivery-lifecyclefrom
juan-fernandez/retry-unknown-test-optimization-network-errors-on-telemetry
Sep 1, 2026
Merged

juan-fernandez merged 3 commits into
juan-fernandez/test-optimization-delivery-lifecyclefrom
juan-fernandez/retry-unknown-test-optimization-network-errors-on-telemetry

Conversation

@juan-fernandez

@juan-fernandez juan-fernandez commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Improves retries for two Test Optimization payload delivery failures observed in Web UI end-to-end runs:

  • Failures that return neither an HTTP status nor an error code receive one retry, including during finalization, without allowing an overlapping final flush to extend that retry budget.
  • Each transport attempt has a total timeout starting at request creation, including local socket-queue time. Retriable final-flush attempts continue while the hard 60-second deadline has capacity.

Coded permanent failures such as ENOTFOUND remain non-retriable, and background requests retain their ordinary attempt cap.

Motivation

Web UI end-to-end runs reported endpoint_payload.requests_errors with both status_code:N/A, error_type:network and error_type:err_dd_test_optimization_request_timeout.

The existing retry classifier only retries an allowlist of coded transient network errors, while the generic network telemetry indicates the failure had no usable error code and therefore was not retried. Separately, removing the total attempt timer allowed a request waiting for a socket to remain pending until the final-flush deadline aborted it, without giving retry handling an opportunity to run.

Two full Web UI runs using the isolated retry experiment completed without payload request errors. A Web UI run using the stacked lifecycle implementation still reported request timeouts, motivating restoration of the total attempt timeout and deadline-bounded final retries in this draft.

Additional Notes

This is a draft stacked directly on #10044, which now contains both the delivery lifecycle and error telemetry changes formerly split across #10044 and #10045.

Verification:

  • 59 combined Test Optimization request, telemetry, and writer tests
  • ESLint on the changed production and test files
  • git diff --check

@dd-octo-sts

dd-octo-sts Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 8.44 MB
Deduped: 9.1 MB
No deduping: 9.1 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-6

datadog-prod-us1-6 Bot commented Aug 31, 2026

Copy link
Copy Markdown

Pipelines  Tests

⚠️ Warnings

⚠️ Your PR has warnings. Please review the issues below.

🚦 1 Pipeline job failed

System Tests | main / End-to-end #16 / nextjs 16

View more details · View in GitHub Actions

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

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

@pr-commenter

pr-commenter Bot commented Aug 31, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-09-01 14:36:19

Comparing candidate commit ffeac6d in PR branch juan-fernandez/retry-unknown-test-optimization-network-errors-on-telemetry with baseline commit cd47b29 in branch juan-fernandez/test-optimization-delivery-lifecycle.

📊 Benchmarking dashboard

Found 1 performance improvements and 0 performance regressions! Performance is the same for 2291 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:encoders-0.4-events-native-20

  • 🟩 max_rss_usage [-10.371MB; -3.586MB] or [-7.289%; -2.520%]

Unstable benchmarks

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

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

  • unstable max_rss_usage [-15.728MB; +25.080MB] or [-6.798%; +10.841%]

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

  • unstable max_rss_usage [-24.772MB; +9.197MB] or [-7.494%; +2.782%]

scenario:debugger-line-probe-with-snapshot-minimal-24

  • unstable max_rss_usage [-11.382MB; +16.342MB] or [-4.544%; +6.524%]

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

  • unstable max_rss_usage [-18.732MB; +8.808MB] or [-7.049%; +3.315%]

scenario:dogstatsd-with-tags-20

  • unstable cpu_user_time [-295589.390µs; +296607.390µs] or [-5.984%; +6.004%]
  • unstable execution_time [-296.033ms; +292.628ms] or [-5.899%; +5.832%]
  • unstable throughput [-102779.467op/s; +103742.675op/s] or [-6.159%; +6.217%]

scenario:fs-subscribed-24

  • unstable execution_time [-21.169ms; +36.192ms] or [-5.218%; +8.922%]

scenario:id-parse-64bit-20

  • unstable execution_time [-101.157ms; +181.604ms] or [-3.960%; +7.110%]

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

  • unstable cpu_usage_percentage [-9.179%; +4.669%]
  • unstable execution_time [-2.702ms; +4.777ms] or [-4.108%; +7.264%]
  • unstable throughput [-34854.088op/s; +21869.345op/s] or [-6.601%; +4.142%]

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

  • unstable cpu_usage_percentage [-3.876%; +6.181%]

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

  • unstable max_rss_usage [-29822.440KB; +29556.840KB] or [-7.605%; +7.537%]

scenario:plugin-pg-service-26

  • unstable cpu_usage_percentage [-10.237%; +9.007%]
  • unstable execution_time [-147.769ms; +183.296ms] or [-15.676%; +19.445%]
  • unstable throughput [-783833.350op/s; +648091.173op/s] or [-11.909%; +9.847%]

scenario:test-optimization-large-suite-20

  • unstable max_rss_usage [-3.344MB; +8.511MB] or [-4.191%; +10.666%]

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (juan-fernandez/test-optimization-delivery-lifecycle@cd47b29). Learn more about missing BASE report.

Additional details and impacted files
@@                                  Coverage Diff                                   @@
##             juan-fernandez/test-optimization-delivery-lifecycle   #10069   +/-   ##
======================================================================================
  Coverage                                                       ?   98.58%           
======================================================================================
  Files                                                          ?      993           
  Lines                                                          ?   149650           
  Branches                                                       ?    13145           
======================================================================================
  Hits                                                           ?   147539           
  Misses                                                         ?     2111           
  Partials                                                       ?        0           
Flag Coverage Δ
aiguard 62.55% <40.00%> (?)
aiguard-integration 59.14% <33.33%> (?)
apm-bucket-0 62.04% <40.00%> (?)
apm-bucket-1 67.56% <40.00%> (?)
apm-bucket-2 67.13% <40.00%> (?)
apm-bucket-3 63.79% <40.00%> (?)
apm-capabilities-tracing 62.55% <100.00%> (?)
apm-integrations-aerospike 59.81% <40.00%> (?)
apm-integrations-confluentinc-kafka-javascript 66.12% <40.00%> (?)
apm-integrations-couchbase 60.35% <40.00%> (?)
apm-integrations-http 65.79% <40.00%> (?)
apm-integrations-kafkajs 66.71% <40.00%> (?)
apm-integrations-next 63.31% <40.00%> (?)
apm-integrations-prisma 61.41% <40.00%> (?)
appsec 76.61% <100.00%> (?)
appsec-express_fastify_graphql 73.03% <40.00%> (?)
appsec-integration 49.25% <40.00%> (?)
appsec-kafka_ldapjs_lodash 67.10% <40.00%> (?)
appsec-mongodb-core_mongoose_mysql 70.38% <40.00%> (?)
appsec-next 56.64% <40.00%> (?)
appsec-node-serialize_passport_postgres 69.83% <40.00%> (?)
appsec-sourcing_stripe_template 68.21% <40.00%> (?)
debugger 68.93% <40.00%> (?)
instrumentations-bucket-0 55.13% <33.33%> (?)
instrumentations-bucket-1 63.65% <40.00%> (?)
instrumentations-bucket-10 64.89% <40.00%> (?)
instrumentations-bucket-11 65.54% <40.00%> (?)
instrumentations-bucket-12 55.01% <40.00%> (?)
instrumentations-bucket-13 55.30% <40.00%> (?)
instrumentations-bucket-14 55.14% <40.00%> (?)
instrumentations-bucket-2 56.22% <40.00%> (?)
instrumentations-bucket-3 57.05% <40.00%> (?)
instrumentations-bucket-4 63.10% <40.00%> (?)
instrumentations-bucket-5 49.33% <40.00%> (?)
instrumentations-bucket-6 64.99% <40.00%> (?)
instrumentations-bucket-7 55.28% <40.00%> (?)
instrumentations-bucket-8 62.47% <40.00%> (?)
instrumentations-bucket-9 57.86% <40.00%> (?)
instrumentations-instrumentation-couchbase 53.67% <33.33%> (?)
instrumentations-integration-esbuild 34.41% <0.00%> (?)
llmobs-ai_anthropic_bedrock 66.36% <40.00%> (?)
llmobs-bucket-1 64.47% <40.00%> (?)
llmobs-openai 66.34% <40.00%> (?)
llmobs-openai-agents_vertex-ai 63.52% <40.00%> (?)
llmobs-sdk 75.77% <40.00%> (?)
openfeature 59.76% <33.33%> (?)
openfeature-unit 57.51% <40.00%> (?)
platform-core_esbuild_instrumentations-misc 40.55% <33.33%> (?)
platform-integration 64.49% <40.00%> (?)
platform-shimmer_unit-guardrails_webpack 38.28% <33.33%> (?)
plugins-browser-bunyan_bullmq_cassandra 65.78% <40.00%> (?)
plugins-bucket-0 60.40% <40.00%> (?)
plugins-bucket-1 57.67% <33.33%> (?)
plugins-bucket-11 66.27% <40.00%> (?)
plugins-bucket-18 65.79% <40.00%> (?)
plugins-bucket-19 64.41% <40.00%> (?)
plugins-bucket-20 66.27% <40.00%> (?)
plugins-bucket-4 60.59% <40.00%> (?)
plugins-cookie_cookie-parser_crypto 54.68% <33.33%> (?)
plugins-fastify_fetch_fs 64.93% <40.00%> (?)
plugins-generic-pool_google-cloud-pubsub_grpc 68.55% <40.00%> (?)
plugins-handlebars_hapi_hono 62.99% <40.00%> (?)
plugins-ioredis_knex_langgraph 61.06% <40.00%> (?)
plugins-ldapjs_light-my-request_limitd-client 62.72% <40.00%> (?)
plugins-lodash_mariadb_memcached 63.34% <40.00%> (?)
plugins-moleculer_mongodb_mongodb-core 65.64% <40.00%> (?)
plugins-mongoose_multer_mysql 63.44% <40.00%> (?)
plugins-mysql2_nats_node-serialize 65.63% <40.00%> (?)
plugins-opensearch_passport-http_pino 63.46% <40.00%> (?)
plugins-postgres_process_pug 62.55% <40.00%> (?)
plugins-redis_router_sequelize 66.23% <40.00%> (?)
plugins-test-and-upstream-rhea_undici_url 65.58% <40.00%> (?)
plugins-valkey_vm_winston 61.86% <40.00%> (?)
plugins-ws 63.86% <40.00%> (?)
profiling 65.88% <40.00%> (?)
serverless-aws-sdk-aws-sdk 54.83% <40.00%> (?)
serverless-aws-sdk-base-inject-field 54.26% <33.33%> (?)
serverless-aws-sdk-bedrockruntime 57.55% <40.00%> (?)
serverless-aws-sdk-client 59.39% <40.00%> (?)
serverless-aws-sdk-dynamodb 58.50% <40.00%> (?)
serverless-aws-sdk-eventbridge 57.07% <40.00%> (?)
serverless-aws-sdk-kinesis 62.59% <40.00%> (?)
serverless-aws-sdk-lambda 60.50% <40.00%> (?)
serverless-aws-sdk-s3 58.57% <40.00%> (?)
serverless-aws-sdk-serverless-peer-service 63.17% <40.00%> (?)
serverless-aws-sdk-sns 63.50% <40.00%> (?)
serverless-aws-sdk-sqs 63.97% <40.00%> (?)
serverless-aws-sdk-stepfunctions 58.38% <40.00%> (?)
serverless-aws-sdk-util 54.93% <33.33%> (?)
serverless-bucket-0 57.11% <33.33%> (?)
serverless-bucket-1 63.13% <40.00%> (?)
test-optimization-cucumber 70.42% <74.28%> (?)
test-optimization-cypress 64.63% <71.42%> (?)
test-optimization-jest 72.08% <91.42%> (?)
test-optimization-mocha 71.93% <75.71%> (?)
test-optimization-playwright-playwright-atr 59.34% <75.71%> (?)
test-optimization-playwright-playwright-efd 60.19% <57.62%> (?)
test-optimization-playwright-playwright-final-status 59.80% <55.93%> (?)
test-optimization-playwright-playwright-impacted-tests 59.91% <55.93%> (?)
test-optimization-playwright-playwright-reporting 60.97% <80.00%> (?)
test-optimization-playwright-playwright-test-management 60.99% <57.62%> (?)
test-optimization-playwright-playwright-test-span 59.60% <75.71%> (?)
test-optimization-selenium 58.62% <62.85%> (?)
test-optimization-testopt 61.69% <75.71%> (?)
test-optimization-vitest 72.53% <62.85%> (?)
test-optimization-vitest-browser 58.48% <55.93%> (?)
test-optimization-webdriverio 65.08% <64.28%> (?)

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.

@juan-fernandez juan-fernandez changed the title fix(test-optimization): retry unknown network errors fix(test-optimization): retry payload delivery failures Aug 31, 2026
@juan-fernandez
juan-fernandez force-pushed the juan-fernandez/retry-unknown-test-optimization-network-errors-on-telemetry branch from 81eef63 to 8e41f23 Compare August 31, 2026 11:54
@juan-fernandez
juan-fernandez changed the base branch from juan-fernandez/test-optimization-error-telemetry to juan-fernandez/test-optimization-delivery-lifecycle August 31, 2026 11:55
@juan-fernandez
juan-fernandez force-pushed the juan-fernandez/retry-unknown-test-optimization-network-errors-on-telemetry branch 5 times, most recently from 9de57a6 to b78bb01 Compare September 1, 2026 14:13
Cap screenshot retries even during finalization, let ready Test Optimization responses beat creation-time timeouts, keep owned agent-discovery retries alive, stabilize Playwright dynamic-name fixtures, and isolate nested integration runs from incomplete GitHub Actions metadata.
@juan-fernandez
juan-fernandez force-pushed the juan-fernandez/retry-unknown-test-optimization-network-errors-on-telemetry branch from b78bb01 to ffeac6d Compare September 1, 2026 14:28
@juan-fernandez
juan-fernandez marked this pull request as ready for review September 1, 2026 14:46
@juan-fernandez
juan-fernandez requested review from a team as code owners September 1, 2026 14:46
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-01T14:53:56.343872Z ffeac6d Draft marked ready
ℹ️ 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.

@juan-fernandez
juan-fernandez merged commit 6dc4c61 into juan-fernandez/test-optimization-delivery-lifecycle Sep 1, 2026
847 of 850 checks passed
@juan-fernandez
juan-fernandez deleted the juan-fernandez/retry-unknown-test-optimization-network-errors-on-telemetry branch September 1, 2026 14:46

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ffeac6d02f

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const initializationController = new AbortController()
const initializationOptions = { signal: initializationController.signal }
const initializationOptions = {
deadline: Date.now() + FINAL_FLUSH_TIMEOUT,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Defer the agent-info deadline until finalization

When the Agent is unavailable while a test framework blocks the event loop for more than 60 seconds, the queued connection error is processed against this already-expired deadline and the request cannot retry even if the Agent is now ready. The exporter then permanently selects the legacy writer and loses EVP features for the session. CiVisibilityExporter.flush() already updates this options object with a fresh shutdown deadline, so setting it during construction reintroduces a startup-relative cutoff that should remain deferred until finalization.

Useful? React with 👍 / 👎.

signal: initializationController.signal,
// Test runners await agent discovery before starting. A detached retry can let Node exit
// while that promise is still pending because promises alone do not keep the event loop alive.
keepProcessAlive: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Do not keep failed discovery retries referenced unconditionally

When the local Agent is down or unreachable, each fast ECONNREFUSED schedules another retry and this option keeps every retry timer referenced; because the new deadline also bypasses the ordinary attempt cap, a short or empty test run is held open for roughly the full 60-second deadline. This also prevents the beforeExit path from reaching the existing empty-buffer fast return in CiVisibilityExporter.flush(), so agent discovery should not own the event loop when there is no delivery work to preserve.

Useful? React with 👍 / 👎.

Comment on lines +301 to +303
const retryUntilDeadline = options.deadline !== undefined && options.retryUntilDeadline !== false
const reachedAttemptLimit = !retryUntilDeadline && attemptIndex >= getMaxAttempts(attemptOptions)
const reachedUnknownNetworkAttemptLimit = isUnknownNetworkError && attemptIndex >= 2

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve an attempt cap for zero-delay rate limits

When a final-flush request receives 429 with a valid zero reset delay—such as Retry-After: 0 or an already-elapsed reset timestamp—this deadline mode removes the attempt cap while the rate-limit branch schedules every retry with setTimeout(..., 0). A persistently rate-limiting intake therefore causes a tight request loop for the remainder of the 60-second finalization window, adding load precisely while the endpoint is throttling; retain a cap or apply a positive backoff for zero-delay 429 responses.

Useful? React with 👍 / 👎.

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.

1 participant