Skip to content

test: unflake async hooks statwatcher test

Under high load 2 types of issues arise with this test.

  • filesystem calls gets queued even when the 'sync' is used which leads to async_hooks being called with the events of tmpdir clean or initial file write after clean. This is solved by counting all 'change' calls while making sure there is no dependency of StatWatcher's on one another and the expected changes are waited for.

  • some events are getting lost with the current clean->write->write_and_watch strategy. Specifically I observed the file size going from 0 (empty) to 5 ('foo++') entirely skipping 3 ('foo') even though the write call was there (this happened reliably on -j128). So I've changed the strategy to avoid additional write considering this still tests the hooks correctly. This may indicate some sort of bug in async_hooks though I'm not sure. Not the async hooks but the fs watcher as it was missing an event.

With these changes, this test reliably passes with -j128 --repeat 4000 on my machine. Time to test this on CI.

Closes: https://github.com/nodejs/node/issues/21425

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

Merge request reports

Loading