Repository: denoland/deno
Pull request: fix(ext/node): emit 'worker' event when a new worker thread is created

As per title. Enables one Node compat test

Changed files:
filename: ext/node/polyfills/process.ts
patch: @@ -89,7 +89,6 @@ const { NumberMAX_SAFE_INTEGER } = primordials;
 
 const notImplementedEvents = [
   "multipleResolves",
-  "worker",
 ];
 
 export const argv: string[] = ["", ""];

filename: ext/node/polyfills/worker_threads.ts
patch: @@ -176,6 +176,7 @@ class NodeWorker extends EventEmitter {
     this.threadId = id;
     this.#pollControl();
     this.#pollMessages();
+    process.nextTick(() => process.emit("worker", this));
   }
 
   [privateWorkerRef](ref) {

filename: tests/node_compat/config.jsonc
patch: @@ -1326,6 +1326,7 @@
       "test-whatwg-url-override-hostname.js",
       "test-whatwg-url-properties.js",
       "test-worker-cleanexit-with-js.js",
+      "test-worker-event.js",
       "test-worker-message-port-infinite-message-loop.js",
       "test-worker-message-port-multiple-sharedarraybuffers.js",
       "test-worker-message-port-receive-message.js",

filename: tests/node_compat/runner/TODO.md
patch: @@ -1,7 +1,7 @@
 <!-- deno-fmt-ignore-file -->
 # Remaining Node Tests
 
-1172 tests out of 3993 have been ported from Node 23.9.0 (29.35% ported, 71.17% remaining).
+1173 tests out of 3993 have been ported from Node 23.9.0 (29.38% ported, 71.15% remaining).
 
 NOTE: This file should not be manually edited. Please edit `tests/node_compat/config.json` and run `deno task setup` in `tests/node_compat/runner` dir instead.
 
@@ -2522,7 +2522,6 @@ NOTE: This file should not be manually edited. Please edit `tests/node_compat/co
 - [parallel/test-worker-esm-missing-main.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-worker-esm-missing-main.js)
 - [parallel/test-worker-esmodule.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-worker-esmodule.js)
 - [parallel/test-worker-eval-typescript.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-worker-eval-typescript.js)
-- [parallel/test-worker-event.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-worker-event.js)
 - [parallel/test-worker-execargv-invalid.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-worker-execargv-invalid.js)
 - [parallel/test-worker-execargv.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-worker-execargv.js)
 - [parallel/test-worker-exit-code.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-worker-exit-code.js)

filename: tests/node_compat/test/parallel/test-worker-event.js
patch: @@ -0,0 +1,21 @@
+// deno-fmt-ignore-file
+// deno-lint-ignore-file
+
+// Copyright Joyent and Node contributors. All rights reserved. MIT license.
+// Taken from Node 23.9.0
+// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
+
+'use strict';
+
+const common = require('../common');
+const assert = require('assert');
+const {
+  Worker,
+  threadId: parentThreadId,
+} = require('worker_threads');
+
+process.on('worker', common.mustCall(({ threadId }) => {
+  assert.strictEqual(threadId, parentThreadId + 1);
+}));
+
+new Worker('', { eval: true });