Skip to content

Commit 828abe1

Browse files
authored
chore: fix unstable log on replay-logs-chronological-order snap-test (#347)
### TL;DR Added a delay before the main process ends to ensure logs are properly flushed to stdout. ### What changed? - Imported the `scheduler` from `node:timers/promises` - Added a 100ms delay using `scheduler.wait(100)` before the main process ends - Added a comment explaining that this delay ensures logs from echo.js are flushed to stdout before the main process terminates ### How to test? Run the replay-logs-chronological-order snap test and verify that all logs from the child processes are properly captured in the output. ### Why make this change? Without this delay, the main process might terminate before all child process logs are properly flushed to stdout, potentially causing logs to be missed or appear out of order in test results. This change ensures more reliable and consistent test output.
1 parent e7285a8 commit 828abe1

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

  • packages/cli/snap-tests/replay-logs-chronological-order

packages/cli/snap-tests/replay-logs-chronological-order/build.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { spawn } from 'node:child_process';
2+
import { scheduler } from 'node:timers/promises';
23

34
async function main() {
45
const commands = [
@@ -42,6 +43,8 @@ async function main() {
4243
await exec(...command);
4344
}
4445

46+
// Wait for 100ms to ensure all child process output streams (e.g., from echo.js via console.warn to stderr) are fully flushed to the parent process before exiting.
47+
await scheduler.wait(100);
4548
console.log('[build.js] main process end');
4649
}
4750

0 commit comments

Comments
 (0)