Skip to content

test(kafkajs): drop retries:0 from header-disable producer tests#9106

Merged
pabloerhard merged 2 commits into
masterfrom
BridgeAR/2026-06-26-kafka-sendbatch-retries
Jun 30, 2026
Merged

test(kafkajs): drop retries:0 from header-disable producer tests#9106
pabloerhard merged 2 commits into
masterfrom
BridgeAR/2026-06-26-kafka-sendbatch-retries

Conversation

@BridgeAR

Copy link
Copy Markdown
Member

Summary

The when broker rejects headers with UNKNOWN_SERVER_ERROR producer tests (send and sendBatch variants) issue a real broker call as their second send, expecting it to succeed once the stub is restored. A fresh topic's first produce routinely returns the retryable NOT_LEADER_FOR_PARTITION while metadata propagates — kafkajs normally refreshes metadata and retries it, but retry: { retries: 0 } stripped that safety net, surfacing the transient error as a hard KafkaJSNonRetriableError and flaking the kafkajs (latest) job.

retries: 0 bought nothing for the first (stubbed) call it was meant to speed up: the stubbed UNKNOWN error is non-retryable, so it already rejects on the first attempt regardless of the retry count (verified against a local 2.2.4 broker — first call fails in ~5 ms, propagates raw, plugin still sees type: 'UNKNOWN'). The 6–8 s seen on 1.4.0 is that version's inherent error-path slowness, already covered by this.timeout(30000), not the retry count.

Why

Removing retries: 0 restores kafkajs's own metadata-refresh-and-retry on the real send while leaving the stubbed-rejection assertions and the header-disable behaviour unchanged. Forcing one transient NOT_LEADER_FOR_PARTITION on the real send against a live broker: with retries: 0 it rejects (KafkaJSNumberOfRetriesExceeded caused by NOT_LEADER_FOR_PARTITION, reproducing the CI failure); with default retries it resolves with errorCode: 0.

Test plan

  • kafkajs matrix (oldest + latest) green

The second sendBatch/send in these tests is a real broker call that the
test expects to succeed after the stub is restored. A fresh topic's first
produce routinely returns the retryable NOT_LEADER_FOR_PARTITION while
metadata propagates; kafkajs normally refreshes metadata and retries it,
but retry:{retries:0} stripped that safety net, surfacing the transient
error as a hard KafkaJSNonRetriableError and flaking CI.

retries:0 bought nothing for the first call it was meant to speed up: the
stubbed UNKNOWN error is non-retryable, so it already fails on the first
attempt regardless of the retry count. Removing it restores the retry on
the real call while leaving the stubbed-rejection assertions unchanged.
@dd-octo-sts

dd-octo-sts Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 6.39 MB
Deduped: 7.46 MB
No deduping: 7.46 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.2.0 | 104.26 kB | 843.44 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-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jun 26, 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.96% (-0.02%)

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

@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.67%. Comparing base (27dcc31) to head (9a870f4).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9106      +/-   ##
==========================================
- Coverage   93.69%   93.67%   -0.02%     
==========================================
  Files         889      889              
  Lines       50856    50856              
  Branches    11830    11830              
==========================================
- Hits        47647    47638       -9     
- Misses       3209     3218       +9     
Flag Coverage Δ
aiguard 34.88% <ø> (-0.08%) ⬇️
aiguard-integration 41.79% <ø> (ø)
apm-bucket-0 34.85% <ø> (-0.08%) ⬇️
apm-bucket-1 40.34% <ø> (-0.07%) ⬇️
apm-bucket-2 37.35% <ø> (-0.07%) ⬇️
apm-capabilities-tracing 48.29% <ø> (ø)
apm-integrations-aerospike 33.13% <ø> (-0.08%) ⬇️
apm-integrations-confluentinc-kafka-javascript 40.04% <ø> (-0.08%) ⬇️
apm-integrations-couchbase 33.41% <ø> (-0.19%) ⬇️
apm-integrations-http 42.04% <ø> (-0.07%) ⬇️
apm-integrations-kafkajs 40.30% <ø> (-0.04%) ⬇️
apm-integrations-next 29.51% <ø> (-0.07%) ⬇️
apm-integrations-prisma 35.04% <ø> (-0.07%) ⬇️
apm-integrations-tedious 33.90% <ø> (-0.08%) ⬇️
appsec 57.37% <ø> (-0.08%) ⬇️
appsec-express_fastify_graphql 53.75% <ø> (-0.06%) ⬇️
appsec-integration 36.25% <ø> (ø)
appsec-kafka_ldapjs_lodash 43.60% <ø> (-0.07%) ⬇️
appsec-mongodb-core_mongoose_mysql 48.82% <ø> (-0.06%) ⬇️
appsec-next 28.01% <ø> (-0.07%) ⬇️
appsec-node-serialize_passport_postgres 48.01% <ø> (-0.06%) ⬇️
appsec-sourcing_stripe_template 45.56% <ø> (-0.06%) ⬇️
debugger 44.42% <ø> (ø)
instrumentations-bucket-0 28.16% <ø> (-0.08%) ⬇️
instrumentations-bucket-1 37.41% <ø> (-0.07%) ⬇️
instrumentations-bucket-10 40.44% <ø> (-0.07%) ⬇️
instrumentations-bucket-11 27.96% <ø> (-0.08%) ⬇️
instrumentations-bucket-12 28.67% <ø> (-0.08%) ⬇️
instrumentations-bucket-13 27.79% <ø> (-0.08%) ⬇️
instrumentations-bucket-2 30.24% <ø> (-0.07%) ⬇️
instrumentations-bucket-3 35.91% <ø> (-0.07%) ⬇️
instrumentations-bucket-4 28.07% <ø> (-0.08%) ⬇️
instrumentations-bucket-5 36.28% <ø> (-0.07%) ⬇️
instrumentations-bucket-6 38.26% <ø> (-0.08%) ⬇️
instrumentations-bucket-7 36.01% <ø> (-0.07%) ⬇️
instrumentations-bucket-8 36.96% <ø> (-0.07%) ⬇️
instrumentations-bucket-9 39.53% <ø> (-0.07%) ⬇️
instrumentations-instrumentation-couchbase 46.54% <ø> (ø)
instrumentations-integration-esbuild 24.87% <ø> (ø)
llmobs-ai_anthropic_bedrock 39.54% <ø> (-0.07%) ⬇️
llmobs-google-genai_langchain_vertex-ai 36.98% <ø> (-0.06%) ⬇️
llmobs-openai 39.59% <ø> (-0.07%) ⬇️
llmobs-sdk 43.60% <ø> (-0.08%) ⬇️
master-coverage 93.67% <ø> (?)
openfeature 37.76% <ø> (ø)
openfeature-unit 50.39% <ø> (ø)
platform-core_esbuild_instrumentations-misc 23.36% <ø> (ø)
platform-integration 47.43% <ø> (ø)
platform-shimmer_unit-guardrails_webpack 18.89% <ø> (ø)
plugins-bucket-0 36.34% <ø> (-0.07%) ⬇️
plugins-bucket-1 39.61% <ø> (ø)
plugins-bucket-11 38.47% <ø> (-0.08%) ⬇️
plugins-bucket-17 39.16% <ø> (-0.07%) ⬇️
plugins-bucket-18 42.01% <ø> (-0.07%) ⬇️
plugins-bucket-19 39.57% <ø> (-0.07%) ⬇️
plugins-bucket-20 43.29% <ø> (-0.07%) ⬇️
plugins-bucket-4 37.72% <ø> (-0.07%) ⬇️
plugins-bullmq_cassandra_cookie 39.77% <ø> (-0.07%) ⬇️
plugins-cookie-parser_crypto_dd-trace-api 33.23% <ø> (-0.08%) ⬇️
plugins-fetch_fs_generic-pool 36.05% <ø> (-0.08%) ⬇️
plugins-google-cloud-pubsub_grpc_handlebars 43.11% <ø> (-0.08%) ⬇️
plugins-hapi_hono_ioredis 37.79% <ø> (-0.07%) ⬇️
plugins-jest_knex_langgraph 32.61% <ø> (-0.08%) ⬇️
plugins-ldapjs_light-my-request_limitd-client 27.85% <ø> (-0.08%) ⬇️
plugins-lodash_mariadb_memcached 35.18% <ø> (-0.08%) ⬇️
plugins-mongodb_mongodb-core_mongoose 36.32% <ø> (-0.07%) ⬇️
plugins-multer_mysql_mysql2 35.15% <ø> (-0.08%) ⬇️
plugins-nats_node-serialize_opensearch 37.16% <ø> (-0.08%) ⬇️
plugins-passport-http_pino_postgres 35.54% <ø> (-0.08%) ⬇️
plugins-process_pug_redis 34.27% <ø> (-0.07%) ⬇️
plugins-undici_url_valkey 35.88% <ø> (-0.07%) ⬇️
plugins-vm_winston_ws 37.56% <ø> (-0.08%) ⬇️
profiling 43.62% <ø> (-0.07%) ⬇️
serverless-aws-sdk-aws-sdk 33.30% <ø> (-0.07%) ⬇️
serverless-aws-sdk-bedrockruntime 32.17% <ø> (-0.07%) ⬇️
serverless-aws-sdk-client 37.21% <ø> (ø)
serverless-aws-sdk-dynamodb 34.10% <ø> (-0.12%) ⬇️
serverless-aws-sdk-eventbridge 27.25% <ø> (-0.07%) ⬇️
serverless-aws-sdk-kinesis 37.41% <ø> (-0.07%) ⬇️
serverless-aws-sdk-lambda 34.60% <ø> (-0.07%) ⬇️
serverless-aws-sdk-s3 32.60% <ø> (-0.07%) ⬇️
serverless-aws-sdk-serverless-peer-service 39.47% <ø> (-0.08%) ⬇️
serverless-aws-sdk-sns 38.26% <ø> (-0.19%) ⬇️
serverless-aws-sdk-sqs 38.01% <ø> (-0.07%) ⬇️
serverless-aws-sdk-stepfunctions 33.19% <ø> (-0.07%) ⬇️
serverless-aws-sdk-util 47.95% <ø> (ø)
serverless-bucket-0 39.47% <ø> (ø)
serverless-lambda 34.33% <ø> (-0.09%) ⬇️
test-optimization-cucumber 52.51% <ø> (+0.05%) ⬆️
test-optimization-cypress 49.73% <ø> (+0.17%) ⬆️
test-optimization-jest 55.67% <ø> (+0.11%) ⬆️
test-optimization-mocha 53.66% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-atr 43.59% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-efd 43.87% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-final-status 43.93% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-impacted-tests 43.41% <ø> (ø)
test-optimization-playwright-playwright-reporting 43.50% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-test-management 44.93% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-test-span 44.78% <ø> (+0.07%) ⬆️
test-optimization-selenium 45.52% <ø> (+0.06%) ⬆️
test-optimization-testopt 48.28% <ø> (+0.08%) ⬆️
test-optimization-vitest 50.93% <ø> (+0.10%) ⬆️

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 Jun 26, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-06-27 15:03:56

Comparing candidate commit 9a870f4 in PR branch BridgeAR/2026-06-26-kafka-sendbatch-retries with baseline commit 27dcc31 in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 2254 metrics, 32 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 [-178.195ms; +173.659ms] or [-6.761%; +6.589%]

scenario:appsec-appsec-enabled-26

  • unstable execution_time [-203392.658µs; +205368.258µs] or [-8.080%; +8.158%]

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

  • unstable execution_time [-162.275ms; +152.053ms] or [-5.650%; +5.294%]

scenario:appsec-control-20

  • unstable execution_time [-162.520ms; +152.264ms] or [-9.387%; +8.794%]

scenario:appsec-control-24

  • unstable execution_time [-107999.467µs; +107771.701µs] or [-8.869%; +8.851%]

scenario:appsec-control-26

  • unstable execution_time [-111543.007µs; +110663.407µs] or [-9.240%; +9.167%]

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

  • unstable cpu_user_time [-2.631s; +0.354s] or [-30.896%; +4.158%]
  • unstable execution_time [-2.641s; +0.352s] or [-28.682%; +3.822%]
  • unstable instructions [-22.7G instructions; +3.0G instructions] or [-32.637%; +4.274%]
  • unstable throughput [-103.884op/s; +769.784op/s] or [-2.840%; +21.044%]

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

  • unstable cpu_user_time [-1842.695ms; +579.310ms] or [-19.701%; +6.194%]
  • unstable execution_time [-1857.627ms; +596.144ms] or [-18.481%; +5.931%]
  • unstable instructions [-16.4G instructions; +5.4G instructions] or [-21.102%; +7.018%]
  • unstable throughput [-138.703op/s; +416.614op/s] or [-4.243%; +12.744%]

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

  • unstable cpu_user_time [-1662.119ms; +530.575ms] or [-21.008%; +6.706%]
  • unstable execution_time [-1673.494ms; +555.102ms] or [-19.512%; +6.472%]
  • unstable instructions [-14.2G instructions; +4.6G instructions] or [-22.104%; +7.112%]
  • unstable throughput [-166.051op/s; +492.163op/s] or [-4.313%; +12.783%]

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

  • unstable cpu_user_time [-1983.649ms; +3359.881ms] or [-21.102%; +35.742%]
  • unstable execution_time [-1993.327ms; +3382.307ms] or [-19.766%; +33.539%]
  • unstable instructions [-17.4G instructions; +29.8G instructions] or [-22.204%; +38.061%]
  • unstable max_rss_usage [-6.680MB; +10.827MB] or [-4.201%; +6.808%]
  • unstable throughput [-745.176op/s; +421.012op/s] or [-22.879%; +12.926%]

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

  • unstable cpu_user_time [-2622.029ms; +2570.950ms] or [-30.887%; +30.286%]
  • unstable execution_time [-2640.653ms; +2595.233ms] or [-28.786%; +28.291%]
  • unstable instructions [-22622.1M instructions; +21983.2M instructions] or [-32.681%; +31.758%]
  • unstable max_rss_usage [-9781.598KB; +9280.798KB] or [-6.107%; +5.794%]
  • unstable throughput [-777.834op/s; +768.998op/s] or [-21.176%; +20.936%]

scenario:dogstatsd-with-tags-20

  • unstable cpu_user_time [-474.807ms; +150.202ms] or [-9.887%; +3.128%]
  • unstable execution_time [-469.406ms; +151.836ms] or [-9.629%; +3.115%]
  • unstable throughput [-53555.879op/s; +159893.471op/s] or [-3.110%; +9.285%]

scenario:plugin-graphql-long-with-depth-on-max-20

  • unstable max_rss_usage [-35.221MB; +70.438MB] or [-18.555%; +37.107%]

@BridgeAR
BridgeAR marked this pull request as ready for review June 26, 2026 21:48
@BridgeAR
BridgeAR requested a review from a team as a code owner June 26, 2026 21:48
@BridgeAR
BridgeAR requested review from tlhunter and removed request for a team June 26, 2026 21:48
@pabloerhard
pabloerhard merged commit 583aa85 into master Jun 30, 2026
1076 of 1077 checks passed
@pabloerhard
pabloerhard deleted the BridgeAR/2026-06-26-kafka-sendbatch-retries branch June 30, 2026 16:16
dd-octo-sts Bot pushed a commit that referenced this pull request Jul 1, 2026
The second sendBatch/send in these tests is a real broker call that the
test expects to succeed after the stub is restored. A fresh topic's first
produce routinely returns the retryable NOT_LEADER_FOR_PARTITION while
metadata propagates; kafkajs normally refreshes metadata and retries it,
but retry:{retries:0} stripped that safety net, surfacing the transient
error as a hard KafkaJSNonRetriableError and flaking CI.

retries:0 bought nothing for the first call it was meant to speed up: the
stubbed UNKNOWN error is non-retryable, so it already fails on the first
attempt regardless of the retry count. Removing it restores the retry on
the real call while leaving the stubbed-rejection assertions unchanged.
This was referenced Jul 1, 2026
rochdev pushed a commit that referenced this pull request Jul 2, 2026
The second sendBatch/send in these tests is a real broker call that the
test expects to succeed after the stub is restored. A fresh topic's first
produce routinely returns the retryable NOT_LEADER_FOR_PARTITION while
metadata propagates; kafkajs normally refreshes metadata and retries it,
but retry:{retries:0} stripped that safety net, surfacing the transient
error as a hard KafkaJSNonRetriableError and flaking CI.

retries:0 bought nothing for the first call it was meant to speed up: the
stubbed UNKNOWN error is non-retryable, so it already fails on the first
attempt regardless of the retry count. Removing it restores the retry on
the real call while leaving the stubbed-rejection assertions unchanged.
rochdev pushed a commit that referenced this pull request Jul 2, 2026
The second sendBatch/send in these tests is a real broker call that the
test expects to succeed after the stub is restored. A fresh topic's first
produce routinely returns the retryable NOT_LEADER_FOR_PARTITION while
metadata propagates; kafkajs normally refreshes metadata and retries it,
but retry:{retries:0} stripped that safety net, surfacing the transient
error as a hard KafkaJSNonRetriableError and flaking CI.

retries:0 bought nothing for the first call it was meant to speed up: the
stubbed UNKNOWN error is non-retryable, so it already fails on the first
attempt regardless of the retry count. Removing it restores the retry on
the real call while leaving the stubbed-rejection assertions unchanged.
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