Skip to content

Commit b8624ab

Browse files
committed
worker,etw: only enable ETW on the main thread
The Windows ETW code is not written to be compatible with multi-threading, and in particular it relies on global state like a single static `uv_async_t`. Adding that to multiple threads would corrupt the corresponding loops' handle queues. This addresses the flakiness of at least `test-worker-exit-code` and very likely other flaky tests that relate to Worker threads on Windows as well. Fixes: nodejs#25847 Fixes: nodejs#25702 Fixes: nodejs#24005 Fixes: nodejs#23873
1 parent d0bce9a commit b8624ab

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/node_dtrace.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,11 @@ void InitDTrace(Environment* env, Local<Object> target) {
288288
}
289289

290290
#ifdef HAVE_ETW
291-
init_etw();
291+
// ETW is neither thread-safe nor does it clean up resources on exit,
292+
// so we can use it only on the main thread.
293+
if (env->is_main_thread()) {
294+
init_etw();
295+
}
292296
#endif
293297

294298
#if defined HAVE_DTRACE || defined HAVE_ETW

0 commit comments

Comments
 (0)