GeezerVison is showing github.com — worker: add Symbol.toStringTag to MessageChannel and MessagePort · nodejs/node@f6f705e
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/worker/io.js +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,6 +15,7 @@ const { | 15 | 15 | ReflectApply, | 16 | 16 | Symbol, | 17 | 17 | SymbolFor, | | 18 | + SymbolToStringTag, | 18 | 19 | } = primordials; | 19 | 20 |
| 20 | 21 | const { | @@ -208,6 +209,18 @@ ObjectDefineProperty(MessagePort.prototype, inspect.custom, { | 208 | 209 | }, | 209 | 210 | }); | 210 | 211 |
| | 212 | +ObjectDefineProperty(MessagePort.prototype, SymbolToStringTag, { | | 213 | + __proto__: null, | | 214 | + configurable: true, | | 215 | + value: 'MessagePort', | | 216 | +}); | | 217 | + | | 218 | +ObjectDefineProperty(MessageChannel.prototype, SymbolToStringTag, { | | 219 | + __proto__: null, | | 220 | + configurable: true, | | 221 | + value: 'MessageChannel', | | 222 | +}); | | 223 | + | 211 | 224 | function setupPortReferencing(port, eventEmitter, eventName) { | 212 | 225 | // Keep track of whether there are any workerMessage listeners: | 213 | 226 | // If there are some, ref() the channel so it keeps the event loop alive. | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-eventtarget-memoryleakwarning.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,12 +15,12 @@ common.expectWarning({ | 15 | 15 | 'EventTarget. MaxListeners is 2. Use events.setMaxListeners() ' + | 16 | 16 | 'to increase limit'], | 17 | 17 | ['Possible EventTarget memory leak detected. 3 foo listeners added to ' + | 18 | | - '[MessagePort [EventTarget]]. ' + | | 18 | + '[MessagePort]. ' + | 19 | 19 | 'MaxListeners is 2. ' + | 20 | 20 | 'Use events.setMaxListeners() to increase ' + | 21 | 21 | 'limit'], | 22 | 22 | ['Possible EventTarget memory leak detected. 3 foo listeners added to ' + | 23 | | - '[MessagePort [EventTarget]]. ' + | | 23 | + '[MessagePort]. ' + | 24 | 24 | 'MaxListeners is 2. ' + | 25 | 25 | 'Use events.setMaxListeners() to increase ' + | 26 | 26 | 'limit'], | |
Collapse file Copy file name to clipboard +17Lines changed: 17 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +'use strict'; | | 2 | + | | 3 | +require('../common'); | | 4 | + | | 5 | +const assert = require('assert'); | | 6 | + | | 7 | +const classesToBeTested = [ MessageChannel, MessagePort ]; | | 8 | + | | 9 | +classesToBeTested.forEach((cls) => { | | 10 | + assert.strictEqual(cls.prototype[Symbol.toStringTag], cls.name); | | 11 | + assert.deepStrictEqual(Object.getOwnPropertyDescriptor(cls.prototype, Symbol.toStringTag), | | 12 | + { configurable: true, enumerable: false, value: cls.name, writable: false }); | | 13 | +}); | | 14 | + | | 15 | +const channel = new MessageChannel(); | | 16 | +assert.strictEqual(Object.prototype.toString.call(channel), '[object MessageChannel]'); | | 17 | +assert.strictEqual(Object.prototype.toString.call(channel.port1), '[object MessagePort]'); |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-worker-message-port-inspect-during-init-hook.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,7 +12,7 @@ async_hooks.createHook({ | 12 | 12 | init: common.mustCall((id, type, triggerId, resource) => { | 13 | 13 | assert.strictEqual( | 14 | 14 | util.inspect(resource), | 15 | | - 'MessagePort [EventTarget] { active: true, refed: false }'); | | 15 | + 'MessagePort { active: true, refed: false }'); | 16 | 16 | }, 2) | 17 | 17 | }).enable(); | 18 | 18 |
| |
|