Skip to content

Commit 23416cc

Browse files
LiviaMedeirostargos
authored andcommitted
worker: give names to MessagePort functions
PR-URL: #58307 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Dario Piotrowicz <dario.piotrowicz@gmail.com>
1 parent 3caa2f7 commit 23416cc

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/internal/worker/io.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const {
1818
} = primordials;
1919

2020
const {
21+
assignFunctionName,
2122
kEnumerableProperty,
2223
setOwnProperty,
2324
} = require('internal/util');
@@ -121,7 +122,7 @@ ObjectSetPrototypeOf(MessagePort.prototype, NodeEventTarget.prototype);
121122
// changing the prototype of MessagePort.prototype implicitly removed them.
122123
MessagePort.prototype.ref = MessagePortPrototype.ref;
123124
MessagePort.prototype.unref = MessagePortPrototype.unref;
124-
MessagePort.prototype.hasRef = function() {
125+
MessagePort.prototype.hasRef = function hasRef() {
125126
return !!FunctionPrototypeCall(MessagePortPrototype.hasRef, this);
126127
};
127128

@@ -131,14 +132,14 @@ ObjectDefineProperty(
131132
kCreateEvent,
132133
{
133134
__proto__: null,
134-
value: function(data, type) {
135+
value: assignFunctionName(kCreateEvent, function(data, type) {
135136
if (type !== 'message' && type !== 'messageerror') {
136137
return ReflectApply(originalCreateEvent, this, arguments);
137138
}
138139
const ports = this[kCurrentlyReceivingPorts];
139140
this[kCurrentlyReceivingPorts] = undefined;
140141
return lazyMessageEvent(type, { data, ports });
141-
},
142+
}),
142143
configurable: false,
143144
writable: false,
144145
enumerable: false,
@@ -179,7 +180,7 @@ ObjectDefineProperty(MessagePort.prototype, handleOnCloseSymbol, {
179180
value: onclose,
180181
});
181182

182-
MessagePort.prototype.close = function(cb) {
183+
MessagePort.prototype.close = function close(cb) {
183184
if (typeof cb === 'function')
184185
this.once('close', cb);
185186
FunctionPrototypeCall(MessagePortPrototype.close, this);

0 commit comments

Comments
 (0)