Skip to content

Commit d699fdd

Browse files
committed
worker: mention argument name in type check message
Refs: #32745 (comment) PR-URL: #32815 Reviewed-By: Zeyu Yang <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]>
1 parent 9534458 commit d699fdd

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/node_messaging.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ void MessagePort::ReceiveMessage(const FunctionCallbackInfo<Value>& args) {
869869
if (!args[0]->IsObject() ||
870870
!env->message_port_constructor_template()->HasInstance(args[0])) {
871871
return THROW_ERR_INVALID_ARG_TYPE(env,
872-
"First argument needs to be a MessagePort instance");
872+
"The \"port\" argument must be a MessagePort instance");
873873
}
874874
MessagePort* port = Unwrap<MessagePort>(args[0].As<Object>());
875875
if (port == nullptr) {
@@ -890,7 +890,7 @@ void MessagePort::MoveToContext(const FunctionCallbackInfo<Value>& args) {
890890
if (!args[0]->IsObject() ||
891891
!env->message_port_constructor_template()->HasInstance(args[0])) {
892892
return THROW_ERR_INVALID_ARG_TYPE(env,
893-
"First argument needs to be a MessagePort instance");
893+
"The \"port\" argument must be a MessagePort instance");
894894
}
895895
MessagePort* port = Unwrap<MessagePort>(args[0].As<Object>());
896896
CHECK_NOT_NULL(port);

test/parallel/test-worker-message-port-receive-message.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ for (const value of [null, 0, -1, {}, []]) {
2828
assert.throws(() => receiveMessageOnPort(value), {
2929
name: 'TypeError',
3030
code: 'ERR_INVALID_ARG_TYPE',
31-
message: 'First argument needs to be a MessagePort instance'
31+
message: 'The "port" argument must be a MessagePort instance'
3232
});
3333
}

0 commit comments

Comments
 (0)