JSConf JP

Waiting for `debug>` Didn't Help: Synchronization Points for Async Operations Learned from Node.js Flaky Tests

LTTrack CJapanese

The Node.js debugger has a flaky test that fails intermittently only in certain CI environments. Waiting for a prompt such as debug> may appear to indicate that the debugger is ready, but the prompt, debugger reconnection, and Debugger.paused events can proceed through separate asynchronous operations. Seeing text on screen does not necessarily mean the internal state is correct.

Using a contribution to Node.js core and the debugger’s flaky test, this LT explains: why the test failed only intermittently; why waiting for a particular string was insufficient; and how to investigate the race condition and find a better synchronization point. The talk includes the actual behavior of the Node.js debugger and practical ways to decide what to wait for in asynchronous tests, even without deep knowledge of Node.js internals.