Commit 357e2df
test(node-integration-tests): Wait for kafkajs GROUP_JOIN before producing (#21074)
## Summary
- Replace the fixed 4s `setTimeout` in
`suites/tracing/kafkajs/scenario.mjs` with a deterministic wait on the
kafkajs `GROUP_JOIN` event.
- Also `await consumer.run(...)` instead of leaving the promise
dangling.
## Why
The kafkajs integration test flaked with the consumer transaction never
arriving within the test timeout. The scenario was:
1. `consumer.subscribe(...)` (awaited)
2. `consumer.run(...)` — **not** awaited
3. `await new Promise(resolve => setTimeout(resolve, 4000))`
4. `producer.send(...)`
On slow CI runners, the consumer group rebalance / join can take longer
than the fixed 4 seconds. Although `fromBeginning: true` lets a
late-joining consumer still read offset 0, when the join is slow enough
the consumer transaction isn't created before the per-test timeout.
Listening for the `GROUP_JOIN` event removes the timing assumption
entirely: we proceed exactly when the consumer is in its group and
actively polling. The listener is registered before `consumer.run()` so
it cannot miss the event.
This mirrors the prior fix for the same suite (#20189, which addressed
transaction ordering) and the same race-on-startup pattern already
documented in the amqplib scenario.
Fixes #21044
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent e505a94 commit 357e2df
1 file changed
Lines changed: 11 additions & 3 deletions
Lines changed: 11 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
27 | 36 | | |
28 | 37 | | |
29 | 38 | | |
30 | 39 | | |
31 | 40 | | |
32 | 41 | | |
33 | | - | |
34 | | - | |
| 42 | + | |
35 | 43 | | |
36 | 44 | | |
37 | 45 | | |
| |||
0 commit comments