worker: give names to `MessagePort` functions · nodejs/node@23416cc
@@ -18,6 +18,7 @@ const {
1818} = primordials;
19192020const {
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.
122123MessagePort.prototype.ref = MessagePortPrototype.ref;
123124MessagePort.prototype.unref = MessagePortPrototype.unref;
124-MessagePort.prototype.hasRef = function() {
125+MessagePort.prototype.hasRef = function hasRef() {
125126return !!FunctionPrototypeCall(MessagePortPrototype.hasRef, this);
126127};
127128@@ -131,14 +132,14 @@ ObjectDefineProperty(
131132kCreateEvent,
132133{
133134__proto__: null,
134-value: function(data, type) {
135+value: assignFunctionName(kCreateEvent, function(data, type) {
135136if (type !== 'message' && type !== 'messageerror') {
136137return ReflectApply(originalCreateEvent, this, arguments);
137138}
138139const ports = this[kCurrentlyReceivingPorts];
139140this[kCurrentlyReceivingPorts] = undefined;
140141return lazyMessageEvent(type, { data, ports });
141-},
142+}),
142143configurable: false,
143144writable: false,
144145enumerable: false,
@@ -179,7 +180,7 @@ ObjectDefineProperty(MessagePort.prototype, handleOnCloseSymbol, {
179180value: onclose,
180181});
181182182-MessagePort.prototype.close = function(cb) {
183+MessagePort.prototype.close = function close(cb) {
183184if (typeof cb === 'function')
184185this.once('close', cb);
185186FunctionPrototypeCall(MessagePortPrototype.close, this);