Skip to content

test: fix timers-same-timeout-wrong-list-deleted

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

test timers

Description of change

test-timers-same-timeout-wrong-list-deleted was flaky under load because there is no guarantee that a timer will fire within a given period of time. It had an exit handler that checked that the process was finishing in less than twice as much as a timer was set for. Under load, the timer could take over 200ms to fire even if it was set for 100ms, so this was causing the test to be flaky on CI from time to time.

However, that timing check is unnecessary to identify the regression that the test was written for. When run with a version of Node.js that does not contain the fix that accompanied the test in its initial commit, an assertion indicating that there were still timers in the active timer list fired. So, this commit removes the exit handler timing check and relies on the existing robust active timers list length check.

This allows us to move the test back to parallel because it does not seem to fail under load anymore.

The test was refactored slightly, removing duplicated code to a function, using assert.strictEqual() instead of assert.equal(), changing a 10ms timer to 1ms, and improving the messages provided by assertions.

Merge request reports

Loading