worker: give names to `MessagePort` functions · nodejs/node@23416cc

@@ -18,6 +18,7 @@ const {

1818

} = primordials;

19192020

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

});

181182182-

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);