Commit b6dc2be
test(kernel-node-runtime): Fix flaky remote-comms E2E tests (#927)
## Description
Two E2E tests in `remote-comms.test.ts` were consistently flaky on
`main`, failing more often than passing:
1. **"rejects new messages when queue reaches MAX_QUEUE limit"** — timed
out at 120s
2. **"resolves promise after reconnection when retries have not been
exhausted"** — failed with `URL redemption timed out after 8000ms`
**Root cause:** Both tests used `testBackoffOptions` with `ackTimeoutMs:
2_000`. The `RemoteHandle` gives up after `ackTimeoutMs × (MAX_RETRIES +
1) = 8s`, which is too short for kernel2 to restart (new DB connection +
kernel init + libp2p + relay connection + vat launch).
## Changes
- Increase `ackTimeoutMs` to `5_000` for both tests, giving a 20s
give-up window instead of 8s
- Extract named options objects (`queueTestOptions`, `reconnectOptions`)
for clarity and consistency between `setupAliceAndBob` and
`restartKernelAndReloadVat` calls
- Restructure the reconnection test to establish the connection first
(completing URL redemption), then stop kernel2 before sending the test
message — eliminating both the URL redemption race and the
non-deterministic message delivery race
- Remove unnecessary `delay()` calls that were masking the underlying
timing issue
## Testing
Both tests pass reliably after the fix. Verified by running the full
`remote-comms.test.ts` E2E suite twice — all 67 E2E tests pass across
all 11 test files (including both previously-flaky tests).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Low risk: changes are limited to E2E test timing/configuration and
message sequencing; main risk is masking real regressions by increasing
timeouts or altering test ordering.
>
> **Overview**
> Stabilizes `remote-comms.test.ts` E2E coverage by introducing per-test
option objects that override `ackTimeoutMs` (to `5_000`) and related
rate-limit settings, and then using those same options consistently
across `setupAliceAndBob` and `restartKernelAndReloadVat`.
>
> Reworks the "reconnect without exhausting retries" test to first
establish a connection (complete URL redemption), then stop the remote
kernel and queue the message while it’s definitely offline, removing
race-prone delays and making the queued-message reconnection behavior
deterministic.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
11d93ec. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 882fd94 commit b6dc2be
1 file changed
Lines changed: 31 additions & 21 deletions
Lines changed: 31 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
569 | 569 | | |
570 | 570 | | |
571 | 571 | | |
572 | | - | |
| 572 | + | |
573 | 573 | | |
574 | | - | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
575 | 584 | | |
576 | 585 | | |
577 | 586 | | |
578 | 587 | | |
579 | 588 | | |
580 | 589 | | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
| 590 | + | |
586 | 591 | | |
587 | 592 | | |
588 | 593 | | |
| |||
607 | 612 | | |
608 | 613 | | |
609 | 614 | | |
610 | | - | |
| 615 | + | |
611 | 616 | | |
612 | 617 | | |
613 | 618 | | |
| |||
1069 | 1074 | | |
1070 | 1075 | | |
1071 | 1076 | | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
1072 | 1084 | | |
1073 | 1085 | | |
1074 | 1086 | | |
1075 | 1087 | | |
1076 | 1088 | | |
1077 | 1089 | | |
1078 | | - | |
| 1090 | + | |
1079 | 1091 | | |
1080 | 1092 | | |
1081 | | - | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
1082 | 1101 | | |
1083 | 1102 | | |
1084 | 1103 | | |
1085 | 1104 | | |
1086 | 1105 | | |
1087 | 1106 | | |
1088 | | - | |
1089 | | - | |
1090 | | - | |
1091 | | - | |
1092 | | - | |
1093 | | - | |
1094 | | - | |
| 1107 | + | |
1095 | 1108 | | |
1096 | 1109 | | |
1097 | 1110 | | |
1098 | 1111 | | |
1099 | 1112 | | |
1100 | 1113 | | |
1101 | 1114 | | |
1102 | | - | |
| 1115 | + | |
1103 | 1116 | | |
1104 | 1117 | | |
1105 | 1118 | | |
1106 | 1119 | | |
1107 | | - | |
1108 | | - | |
1109 | | - | |
1110 | 1120 | | |
1111 | 1121 | | |
1112 | 1122 | | |
| |||
0 commit comments