Repository: denoland/deno
Pull request: fix(ext/node): update message for `MaxListenersExceededWarning`

This PR updates warning message for `MaxListenersExceededWarning`

towards #29595

Changed files:
filename: ext/node/polyfills/_events.mjs
patch: @@ -469,8 +469,8 @@ function _addListener(target, type, listener, prepend) {
       const w = new Error(
         "Possible EventEmitter memory leak detected. " +
           `${existing.length} ${String(type)} listeners ` +
-          `added to ${inspect(target, { depth: -1 })}. Use ` +
-          "emitter.setMaxListeners() to increase limit",
+          `added to ${inspect(target, { depth: -1 })}. ` +
+          `MaxListeners is ${m}.`,
       );
       w.name = "MaxListenersExceededWarning";
       w.emitter = target;

filename: tests/node_compat/config.jsonc
patch: @@ -72,9 +72,6 @@
       "test-dsa-fips-invalid-key.js",
       "test-error-aggregateTwoErrors.js",
       "test-error-prepare-stack-trace.js",
-      "test-event-emitter-max-listeners-warning-for-null.js",
-      "test-event-emitter-max-listeners-warning-for-symbol.js",
-      "test-event-emitter-max-listeners-warning.js",
       "test-event-emitter-max-listeners.js",
       "test-event-emitter-no-error-provided-to-error-event.js",
       "test-event-emitter-prepend.js",

filename: tests/node_compat/test/parallel/test-event-emitter-max-listeners-warning-for-null.js
patch: @@ -2,7 +2,7 @@
 // deno-lint-ignore-file
 
 // Copyright Joyent and Node contributors. All rights reserved. MIT license.
-// Taken from Node 20.11.1
+// Taken from Node 23.9.0
 // This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
 
 // Flags: --no-warnings
@@ -23,7 +23,7 @@ process.on('warning', common.mustCall((warning) => {
   assert.strictEqual(warning.count, 2);
   assert.strictEqual(warning.type, null);
   assert.ok(warning.message.includes(
-    '2 null listeners added to [EventEmitter].'));
+    '2 null listeners added to [EventEmitter]. MaxListeners is 1.'));
 }));
 
 e.on(null, () => {});

filename: tests/node_compat/test/parallel/test-event-emitter-max-listeners-warning-for-symbol.js
patch: @@ -2,7 +2,7 @@
 // deno-lint-ignore-file
 
 // Copyright Joyent and Node contributors. All rights reserved. MIT license.
-// Taken from Node 20.11.1
+// Taken from Node 23.9.0
 // This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
 
 // Flags: --no-warnings
@@ -25,7 +25,7 @@ process.on('warning', common.mustCall((warning) => {
   assert.strictEqual(warning.count, 2);
   assert.strictEqual(warning.type, symbol);
   assert.ok(warning.message.includes(
-    '2 Symbol(symbol) listeners added to [EventEmitter].'));
+    '2 Symbol(symbol) listeners added to [EventEmitter]. MaxListeners is 1.'));
 }));
 
 e.on(symbol, () => {});

filename: tests/node_compat/test/parallel/test-event-emitter-max-listeners-warning.js
patch: @@ -2,7 +2,7 @@
 // deno-lint-ignore-file
 
 // Copyright Joyent and Node contributors. All rights reserved. MIT license.
-// Taken from Node 20.11.1
+// Taken from Node 23.9.0
 // This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
 
 // Flags: --no-warnings
@@ -30,7 +30,7 @@ process.on('warning', common.mustCall((warning) => {
   assert.strictEqual(warning.count, 2);
   assert.strictEqual(warning.type, 'event-type');
   assert.ok(warning.message.includes(
-    '2 event-type listeners added to [FakeInput].'));
+    '2 event-type listeners added to [FakeInput]. MaxListeners is 1.'));
 }));
 
 e.on('event-type', () => {});