Skip to content

fix(playwright): ignore intermediate retry failures in aggregate status#9231

Merged
juan-fernandez merged 1 commit into
masterfrom
juan-fernandez/fix-playwright-flaky-aggregate-status
Jul 7, 2026
Merged

fix(playwright): ignore intermediate retry failures in aggregate status#9231
juan-fernandez merged 1 commit into
masterfrom
juan-fernandez/fix-playwright-flaky-aggregate-status

Conversation

@juan-fernandez

@juan-fernandez juan-fernandez commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Fixes Playwright Test Optimization aggregate reporting for flaky tests that pass after retry.

Failed retry attempts are still reported as failed test events, but they no longer make the final suite, module, or session events look failed when Playwright eventually passes the test.

Motivation

For example, consider a Playwright test that fails on the first attempt and passes on retry. The test-level events are expected to show both attempts:

  • first attempt: test.status=fail
  • retry attempt: test.status=pass, test.is_retry=true, test.retry_reason=auto_test_retry, test.final_status=pass

Before this fix, the aggregate events could still reflect the intermediate failed attempt:

  • test_suite_end was reported as failed
  • test_module_end and test_session_end could report test.status=pass while also carrying error=1 and Test suites failed: 1.

That made a flaky-successful Playwright run look contradictory: the test retry passed, but the suite/session payload still looked failed. The root cause was that failed intermediate retry attempts were recorded into aggregate suite status and error state before Playwright had finished retrying the test.

This change only records suite status and suite errors once Playwright is done retrying that test, and only attaches session/module aggregate errors when the final session status failed.

Additional Notes

Added integration coverage for the flaky-success case so the final suite, module, and session events are passing and error-free when the final Playwright retry passes. Existing coverage still verifies that tests which exhaust all ATR attempts continue to report failure.

@dd-octo-sts

dd-octo-sts Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 6.57 MB
Deduped: 7.23 MB
No deduping: 7.23 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.3.0 | 117.14 kB | 432.47 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

@pr-commenter

pr-commenter Bot commented Jul 7, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-07-07 08:42:54

Comparing candidate commit 32096e4 in PR branch juan-fernandez/fix-playwright-flaky-aggregate-status with baseline commit 37a5069 in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 2245 metrics, 41 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-24

  • unstable execution_time [-176677.379µs; +176102.979µs] or [-6.732%; +6.710%]

scenario:appsec-appsec-enabled-26

  • unstable execution_time [-207429.278µs; +206215.812µs] or [-8.243%; +8.195%]

scenario:appsec-appsec-enabled-with-attacks-26

  • unstable execution_time [-157.636ms; +150.414ms] or [-5.478%; +5.227%]

scenario:appsec-control-20

  • unstable execution_time [-108.482ms; +118.988ms] or [-6.712%; +7.362%]

scenario:appsec-control-24

  • unstable execution_time [-103614.015µs; +104655.582µs] or [-8.532%; +8.617%]

scenario:appsec-control-26

  • unstable execution_time [-112990.045µs; +111352.378µs] or [-9.361%; +9.226%]

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

  • unstable cpu_user_time [-1661.970ms; +351.009ms] or [-19.235%; +4.063%]
  • unstable execution_time [-1685.249ms; +350.482ms] or [-18.071%; +3.758%]
  • unstable instructions [-13.8G instructions; +2.8G instructions] or [-19.627%; +4.018%]
  • unstable throughput [-100.830op/s; +523.291op/s] or [-2.879%; +14.942%]

scenario:debugger-line-probe-with-snapshot-default-26

  • unstable cpu_user_time [-2183.958ms; +3265.801ms] or [-23.607%; +35.301%]
  • unstable execution_time [-2173.200ms; +3270.817ms] or [-21.858%; +32.897%]
  • unstable instructions [-19.4G instructions; +28.9G instructions] or [-25.240%; +37.617%]
  • unstable throughput [-728.811op/s; +508.984op/s] or [-22.033%; +15.388%]

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

  • unstable cpu_user_time [-1834.640ms; +3392.459ms] or [-20.283%; +37.506%]
  • unstable execution_time [-1826.866ms; +3428.165ms] or [-18.775%; +35.232%]
  • unstable instructions [-15.4G instructions; +28.8G instructions] or [-20.774%; +38.936%]
  • unstable max_rss_usage [-6.874MB; +14.470MB] or [-4.332%; +9.118%]
  • unstable throughput [-938.783op/s; +538.767op/s] or [-27.639%; +15.862%]

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

  • unstable cpu_user_time [-1888.581ms; +586.785ms] or [-20.338%; +6.319%]
  • unstable execution_time [-1891.717ms; +594.930ms] or [-19.005%; +5.977%]
  • unstable instructions [-16.9G instructions; +5.2G instructions] or [-21.806%; +6.718%]
  • unstable throughput [-134.030op/s; +427.711op/s] or [-4.056%; +12.942%]

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

  • unstable cpu_user_time [-1162.518ms; +1024.364ms] or [-13.713%; +12.083%]
  • unstable execution_time [-1168.911ms; +1039.832ms] or [-12.745%; +11.337%]
  • unstable instructions [-9749.2M instructions; +8632.2M instructions] or [-14.119%; +12.501%]
  • unstable throughput [-387.312op/s; +251.861op/s] or [-10.787%; +7.015%]

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

  • unstable cpu_user_time [-4461.956ms; +2962.557ms] or [-37.475%; +24.882%]
  • unstable execution_time [-4549.645ms; +2995.192ms] or [-36.053%; +23.735%]
  • unstable instructions [-39.8G instructions; +25.8G instructions] or [-39.454%; +25.591%]
  • unstable max_rss_usage [-13.804MB; +8.840MB] or [-8.242%; +5.279%]
  • unstable throughput [-667.194op/s; +989.494op/s] or [-24.416%; +36.210%]

scenario:dogstatsd-with-tags-20

  • unstable cpu_user_time [-253.356ms; +430.165ms] or [-5.099%; +8.657%]
  • unstable execution_time [-255.620ms; +430.121ms] or [-5.069%; +8.529%]
  • unstable throughput [-147677.582op/s; +87180.781op/s] or [-8.867%; +5.235%]

scenario:plugin-aws-sdk-lambda-inject-with-context-24

  • unstable cpu_user_time [-216154.160µs; +216118.160µs] or [-5.571%; +5.570%]
  • unstable execution_time [-214752.549µs; +216606.449µs] or [-5.499%; +5.546%]
  • unstable throughput [-27352.389op/s; +26341.673op/s] or [-5.302%; +5.107%]

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

  • unstable max_rss_usage [-26.383MB; +20.106MB] or [-6.950%; +5.297%]

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

  • unstable max_rss_usage [-7478.248KB; +7835.962KB] or [-5.673%; +5.944%]

scenario:test-optimization-large-suite-20

  • unstable max_rss_usage [-5349.194KB; +3521.527KB] or [-6.656%; +4.382%]

@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Jul 7, 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: 87.69% (-0.02%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 32096e4 | Docs | Datadog PR Page | Give us feedback!

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.53%. Comparing base (37a5069) to head (32096e4).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9231      +/-   ##
==========================================
- Coverage   93.55%   93.53%   -0.03%     
==========================================
  Files         900      900              
  Lines       52941    52944       +3     
  Branches    12491    12492       +1     
==========================================
- Hits        49531    49523       -8     
- Misses       3410     3421      +11     
Flag Coverage Δ
aiguard 34.97% <ø> (-0.08%) ⬇️
aiguard-integration 41.96% <ø> (+<0.01%) ⬆️
apm-bucket-0 34.89% <ø> (-0.08%) ⬇️
apm-bucket-1 40.49% <ø> (-0.07%) ⬇️
apm-bucket-2 37.48% <ø> (-0.07%) ⬇️
apm-capabilities-tracing 48.94% <0.00%> (-0.01%) ⬇️
apm-integrations-aerospike 33.11% <ø> (-0.08%) ⬇️
apm-integrations-confluentinc-kafka-javascript 40.01% <ø> (-0.08%) ⬇️
apm-integrations-couchbase 33.23% <ø> (-0.24%) ⬇️
apm-integrations-http 42.04% <ø> (-0.07%) ⬇️
apm-integrations-kafkajs 40.25% <ø> (-0.08%) ⬇️
apm-integrations-next 29.61% <ø> (-0.08%) ⬇️
apm-integrations-prisma 35.17% <ø> (-0.07%) ⬇️
apm-integrations-tedious 34.03% <ø> (-0.08%) ⬇️
appsec 57.87% <ø> (ø)
appsec-express_fastify_graphql 53.86% <ø> (-0.08%) ⬇️
appsec-integration 35.34% <0.00%> (-0.01%) ⬇️
appsec-kafka_ldapjs_lodash 43.74% <ø> (-0.07%) ⬇️
appsec-mongodb-core_mongoose_mysql 48.88% <ø> (-0.06%) ⬇️
appsec-next 27.66% <ø> (-0.07%) ⬇️
appsec-node-serialize_passport_postgres 48.07% <ø> (-0.06%) ⬇️
appsec-sourcing_stripe_template 45.62% <ø> (-0.06%) ⬇️
debugger 44.61% <ø> (ø)
instrumentations-bucket-0 28.15% <ø> (-0.08%) ⬇️
instrumentations-bucket-1 37.59% <ø> (-0.07%) ⬇️
instrumentations-bucket-10 40.50% <ø> (-0.07%) ⬇️
instrumentations-bucket-11 27.95% <ø> (-0.08%) ⬇️
instrumentations-bucket-12 28.78% <ø> (-0.08%) ⬇️
instrumentations-bucket-13 27.78% <ø> (-0.08%) ⬇️
instrumentations-bucket-2 30.35% <ø> (-0.08%) ⬇️
instrumentations-bucket-3 36.05% <ø> (-0.07%) ⬇️
instrumentations-bucket-4 28.59% <ø> (-0.08%) ⬇️
instrumentations-bucket-5 36.41% <ø> (-0.07%) ⬇️
instrumentations-bucket-6 38.41% <ø> (-0.08%) ⬇️
instrumentations-bucket-7 36.13% <ø> (-0.07%) ⬇️
instrumentations-bucket-8 37.09% <ø> (-0.07%) ⬇️
instrumentations-bucket-9 39.60% <ø> (-0.07%) ⬇️
instrumentations-instrumentation-couchbase 46.48% <ø> (ø)
instrumentations-integration-esbuild 24.29% <0.00%> (-0.01%) ⬇️
llmobs-ai_anthropic_bedrock 39.67% <ø> (-0.07%) ⬇️
llmobs-google-genai_langchain_vertex-ai 36.97% <ø> (-0.06%) ⬇️
llmobs-openai 39.73% <ø> (-0.07%) ⬇️
llmobs-sdk 43.57% <ø> (-0.08%) ⬇️
master-coverage 93.53% <100.00%> (?)
openfeature 37.92% <ø> (-0.01%) ⬇️
openfeature-unit 50.47% <ø> (ø)
platform-core_esbuild_instrumentations-misc 22.72% <0.00%> (-0.01%) ⬇️
platform-integration 47.56% <ø> (+0.01%) ⬆️
platform-shimmer_unit-guardrails_webpack 18.25% <0.00%> (-0.01%) ⬇️
plugins-bucket-0 36.51% <ø> (-0.07%) ⬇️
plugins-bucket-1 39.76% <ø> (ø)
plugins-bucket-11 38.61% <ø> (-0.08%) ⬇️
plugins-bucket-17 39.05% <ø> (-0.23%) ⬇️
plugins-bucket-18 42.16% <ø> (-0.07%) ⬇️
plugins-bucket-19 39.96% <ø> (-0.07%) ⬇️
plugins-bucket-20 43.42% <ø> (-0.07%) ⬇️
plugins-bucket-4 37.88% <ø> (-0.07%) ⬇️
plugins-bullmq_cassandra_cookie 39.91% <ø> (-0.07%) ⬇️
plugins-cookie-parser_crypto_dd-trace-api 33.21% <ø> (-0.08%) ⬇️
plugins-fetch_fs_generic-pool 36.19% <ø> (-0.08%) ⬇️
plugins-google-cloud-pubsub_grpc_handlebars 43.07% <ø> (-0.07%) ⬇️
plugins-hapi_hono_ioredis 37.93% <ø> (-0.07%) ⬇️
plugins-jest_knex_langgraph 32.60% <ø> (-0.08%) ⬇️
plugins-ldapjs_light-my-request_limitd-client 27.85% <ø> (-0.08%) ⬇️
plugins-lodash_mariadb_memcached 35.16% <ø> (-0.08%) ⬇️
plugins-mongodb_mongodb-core_mongoose 36.45% <ø> (-0.07%) ⬇️
plugins-multer_mysql_mysql2 35.13% <ø> (-0.08%) ⬇️
plugins-nats_node-serialize_opensearch 37.29% <ø> (-0.08%) ⬇️
plugins-passport-http_pino_postgres 35.52% <ø> (-0.08%) ⬇️
plugins-process_pug_redis 34.25% <ø> (-0.08%) ⬇️
plugins-undici_url_valkey 35.89% <ø> (-0.20%) ⬇️
plugins-vm_winston_ws 37.70% <ø> (-0.08%) ⬇️
profiling 43.82% <ø> (-0.07%) ⬇️
serverless-aws-sdk-aws-sdk 33.31% <ø> (-0.07%) ⬇️
serverless-aws-sdk-bedrockruntime 32.18% <ø> (-0.07%) ⬇️
serverless-aws-sdk-client 37.16% <ø> (ø)
serverless-aws-sdk-dynamodb 34.12% <ø> (-0.12%) ⬇️
serverless-aws-sdk-eventbridge 27.35% <ø> (-0.07%) ⬇️
serverless-aws-sdk-kinesis 37.53% <ø> (-0.07%) ⬇️
serverless-aws-sdk-lambda 34.62% <ø> (?)
serverless-aws-sdk-s3 32.62% <ø> (-0.07%) ⬇️
serverless-aws-sdk-serverless-peer-service 39.63% <ø> (-0.08%) ⬇️
serverless-aws-sdk-sns 38.39% <ø> (-0.07%) ⬇️
serverless-aws-sdk-sqs 38.13% <ø> (-0.07%) ⬇️
serverless-aws-sdk-stepfunctions 33.21% <ø> (-0.07%) ⬇️
serverless-aws-sdk-util 47.95% <ø> (ø)
serverless-azure-functions-servicebus_lambda ?
serverless-bucket-0 39.62% <ø> (+0.99%) ⬆️
serverless-lambda 34.32% <ø> (?)
test-optimization-cucumber 52.33% <ø> (+0.05%) ⬆️
test-optimization-cypress 50.04% <ø> (+0.06%) ⬆️
test-optimization-jest 55.87% <ø> (+0.01%) ⬆️
test-optimization-mocha 53.47% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-atr 43.42% <100.00%> (-0.15%) ⬇️
test-optimization-playwright-playwright-efd 43.71% <100.00%> (+0.09%) ⬆️
test-optimization-playwright-playwright-final-status 43.82% <100.00%> (+0.08%) ⬆️
test-optimization-playwright-playwright-impacted-tests 43.25% <100.00%> (+<0.01%) ⬆️
test-optimization-playwright-playwright-reporting 43.37% <100.00%> (+0.09%) ⬆️
test-optimization-playwright-playwright-test-management 44.82% <100.00%> (-0.13%) ⬇️
test-optimization-playwright-playwright-test-span 44.61% <100.00%> (+0.08%) ⬆️
test-optimization-selenium 45.35% <ø> (+0.06%) ⬆️
test-optimization-testopt 46.68% <83.33%> (+0.09%) ⬆️
test-optimization-vitest 52.65% <ø> (+0.09%) ⬆️

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

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 32096e43fd

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

@juan-fernandez
juan-fernandez marked this pull request as ready for review July 7, 2026 09:50
@juan-fernandez
juan-fernandez requested a review from a team as a code owner July 7, 2026 09:50

@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: 32096e43fd

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

} else {
testSuiteToTestStatuses.set(testSuiteAbsolutePath, [testStatus])
}
if (!willRetry) {

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 Preserve failed attempts when retries never run

This drops the failed attempt from suite aggregation as soon as Playwright reports that it can retry, but that retry is not guaranteed to emit a later testEnd (for example, the run can be stopped by max-failures after another parallel failure or interrupted before the retry starts). In that case the test remains in remainingTestsByFile and the end-of-run fallback reports it as skipped, so the suite can finish without the original failure/error even though a failed test event was emitted. Consider keeping the pending failure and clearing it only when a later retry actually passes.

Useful? React with 👍 / 👎.

@datadog-prod-us1-4 datadog-prod-us1-4 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.

Datadog Autotest: PASS

More details

The fix correctly defers suite status and error recording until tests complete retries, ensuring that intermediate failures don't pollute aggregate events. When a Playwright test fails then passes on retry, the final session/module/suite events now correctly report all-pass status with no error message, fixing the contradictory event state that previously occurred.

Was this helpful? React 👍 or 👎

📊 Validated against 3 scenarios · Open Bits AI session

🤖 Datadog Autotest · Commit 32096e4 · What is Autotest? · Any feedback? Reach out in #autotest

@juan-fernandez
juan-fernandez merged commit d473d38 into master Jul 7, 2026
654 checks passed
@juan-fernandez
juan-fernandez deleted the juan-fernandez/fix-playwright-flaky-aggregate-status branch July 7, 2026 10:07
@dd-octo-sts dd-octo-sts Bot mentioned this pull request Jul 7, 2026
@dd-octo-sts dd-octo-sts Bot mentioned this pull request Jul 7, 2026
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