Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
worker: give names to MessagePort functions
  • Loading branch information
LiviaMedeiros committed May 11, 2025
commit ac4c5ac9cf9cd535e4123469d8d37a3ec68b6935
9 changes: 5 additions & 4 deletions lib/internal/worker/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const {
} = primordials;

const {
assignFunctionName,
kEnumerableProperty,
setOwnProperty,
} = require('internal/util');
Expand Down Expand Up @@ -121,7 +122,7 @@ ObjectSetPrototypeOf(MessagePort.prototype, NodeEventTarget.prototype);
// changing the prototype of MessagePort.prototype implicitly removed them.
MessagePort.prototype.ref = MessagePortPrototype.ref;
MessagePort.prototype.unref = MessagePortPrototype.unref;
MessagePort.prototype.hasRef = function() {
MessagePort.prototype.hasRef = function hasRef() {
return !!FunctionPrototypeCall(MessagePortPrototype.hasRef, this);
};

Expand All @@ -131,14 +132,14 @@ ObjectDefineProperty(
kCreateEvent,
{
__proto__: null,
value: function(data, type) {
value: assignFunctionName(kCreateEvent, function(data, type) {
if (type !== 'message' && type !== 'messageerror') {
return ReflectApply(originalCreateEvent, this, arguments);
}
const ports = this[kCurrentlyReceivingPorts];
this[kCurrentlyReceivingPorts] = undefined;
return lazyMessageEvent(type, { data, ports });
},
}),
configurable: false,
writable: false,
enumerable: false,
Expand Down Expand Up @@ -179,7 +180,7 @@ ObjectDefineProperty(MessagePort.prototype, handleOnCloseSymbol, {
value: onclose,
});

MessagePort.prototype.close = function(cb) {
MessagePort.prototype.close = function close(cb) {
if (typeof cb === 'function')
this.once('close', cb);
FunctionPrototypeCall(MessagePortPrototype.close, this);
Expand Down