test: fix flaky test-worker-debug
Address a race condition in the test; the Worker’s exit events may have been not recorded because the Worker exited before the listeners were attached.
Fix the by attaching the event listeners before telling the Worker to exit.
Fixes: https://github.com/nodejs/node/issues/28299 Fixes: https://github.com/nodejs/node/issues/28106
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines