test(kafkajs): drop retries:0 from header-disable producer tests#9106
Conversation
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.
Overall package sizeSelf size: 6.39 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 |
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 9a870f4 | Docs | Datadog PR Page | Give us feedback! |
Codecov Report✅ All modified and coverable lines are covered by tests. 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 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
BenchmarksBenchmark execution time: 2026-06-27 15:03:56 Comparing candidate commit 9a870f4 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2254 metrics, 32 unstable metrics.
|
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.
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.
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.
Summary
The
when broker rejects headers with UNKNOWN_SERVER_ERRORproducer tests (sendandsendBatchvariants) 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 retryableNOT_LEADER_FOR_PARTITIONwhile metadata propagates — kafkajs normally refreshes metadata and retries it, butretry: { retries: 0 }stripped that safety net, surfacing the transient error as a hardKafkaJSNonRetriableErrorand flaking thekafkajs (latest)job.retries: 0bought nothing for the first (stubbed) call it was meant to speed up: the stubbedUNKNOWNerror 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 seestype: 'UNKNOWN'). The 6–8 s seen on 1.4.0 is that version's inherent error-path slowness, already covered bythis.timeout(30000), not the retry count.Why
Removing
retries: 0restores 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 transientNOT_LEADER_FOR_PARTITIONon the real send against a live broker: withretries: 0it rejects (KafkaJSNumberOfRetriesExceededcaused byNOT_LEADER_FOR_PARTITION, reproducing the CI failure); with default retries it resolves witherrorCode: 0.Test plan
kafkajsmatrix (oldest + latest) green