Skip to content

Commit 5da364a

Browse files
committed
test(replay): make handleNetworkBreadcrumbs flush robust to await depth
waitForReplayEventBuffer hardcoded "one Promise.resolve() per await in the util functions", so it silently coupled the test to the enrichment chain's exact await count. That made a behavior-neutral lint fix (dropping a redundant `return await` in _getResponseText) look like a data-loss regression. Flush microtasks in a bounded loop instead, so the test no longer depends on the implementation's await depth. _getResponseText keeps the rule-compliant `return response.text()`.
1 parent ce6c734 commit 5da364a

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

packages/replay-internal/test/unit/coreHandlers/handleNetworkBreadcrumbs.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import { BASE_TIMESTAMP } from '../..';
2121
import { setupReplayContainer } from '../../utils/setupReplayContainer';
2222

2323
async function waitForReplayEventBuffer() {
24-
// Need one Promise.resolve() per await in the util functions
25-
await Promise.resolve();
26-
await Promise.resolve();
27-
await Promise.resolve();
28-
await Promise.resolve();
29-
await Promise.resolve();
24+
// Flush pending microtasks so the async network-breadcrumb enrichment settles into the buffer.
25+
// Looping a fixed number of times (rather than one `Promise.resolve()` per await in the impl)
26+
// keeps this robust to the enrichment chain's exact await depth.
27+
for (let i = 0; i < 10; i++) {
28+
await Promise.resolve();
29+
}
3030
}
3131

3232
const LARGE_BODY = 'a'.repeat(NETWORK_BODY_MAX_SIZE + 1);

0 commit comments

Comments
 (0)