Skip to content

Commit 5ef5116

Browse files
addaleaxjasnell
authored andcommitted
worker: rename error code to be more accurate
Rename `ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST` to `ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST` in order to be more accurate. PR-URL: #33872 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent 8e12962 commit 5ef5116

File tree

5 files changed

+30
-12
lines changed

5 files changed

+30
-12
lines changed

doc/api/errors.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,12 +1597,20 @@ strict compliance with the API specification (which in some cases may accept
15971597
For APIs that accept options objects, some options might be mandatory. This code
15981598
is thrown if a required option is missing.
15991599

1600-
<a id="ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST"></a>
1601-
### `ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST`
1600+
<a id="ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST"></a>
1601+
### `ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST`
1602+
<!-- YAML
1603+
added: REPLACEME
1604+
-->
16021605

16031606
An object that needs to be explicitly listed in the `transferList` argument
1604-
was found in the object passed to a `postMessage()` call, but not provided in
1605-
the `transferList` for that call. Usually, this is a `MessagePort`.
1607+
was found in the object passed to a [`postMessage()`][] call, but not provided
1608+
in the `transferList` for that call. Usually, this is a `MessagePort`.
1609+
1610+
In Node.js versions prior to REPLACEME, the error code being used here was
1611+
[`ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST`][]. However, the set of
1612+
transferable object types has been expanded to cover more types than
1613+
`MessagePort`.
16061614

16071615
<a id="ERR_MISSING_PASSPHRASE"></a>
16081616
### `ERR_MISSING_PASSPHRASE`
@@ -2442,6 +2450,16 @@ Used when an invalid character is found in an HTTP response status message
24422450
-->
24432451
A given index was out of the accepted range (e.g. negative offsets).
24442452

2453+
<a id="ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST"></a>
2454+
### `ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST`
2455+
<!-- YAML
2456+
removed: REPLACEME
2457+
-->
2458+
2459+
This error code was replaced by [`ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST`][]
2460+
in Node.js REPLACEME, because it is no longer accurate as other types of
2461+
transferable objects also exist now.
2462+
24452463
<a id="ERR_NAPI_CONS_PROTOTYPE_OBJECT"></a>
24462464
### `ERR_NAPI_CONS_PROTOTYPE_OBJECT`
24472465
<!-- YAML
@@ -2693,6 +2711,8 @@ such as `process.stdout.on('data')`.
26932711
[`--force-fips`]: cli.html#cli_force_fips
26942712
[`Class: assert.AssertionError`]: assert.html#assert_class_assert_assertionerror
26952713
[`ERR_INVALID_ARG_TYPE`]: #ERR_INVALID_ARG_TYPE
2714+
[`ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST`]: #ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST
2715+
[`ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST`]: #ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST
26962716
[`EventEmitter`]: events.html#events_class_eventemitter
26972717
[`MessagePort`]: worker_threads.html#worker_threads_class_messageport
26982718
[`Object.getPrototypeOf`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf
@@ -2725,6 +2745,7 @@ such as `process.stdout.on('data')`.
27252745
[`net`]: net.html
27262746
[`new URL(input)`]: url.html#url_new_url_input_base
27272747
[`new URLSearchParams(iterable)`]: url.html#url_new_urlsearchparams_iterable
2748+
[`postMessage()`]: worker_threads.html#worker_threads_port_postmessage_value_transferlist
27282749
[`process.on('exit')`]: process.html#Event:-`'exit'`
27292750
[`process.send()`]: process.html#process_process_send_message_sendhandle_options_callback
27302751
[`process.setUncaughtExceptionCaptureCallback()`]: process.html#process_process_setuncaughtexceptioncapturecallback_fn

src/node_errors.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void OnFatalError(const char* location, const char* message);
4343
V(ERR_MEMORY_ALLOCATION_FAILED, Error) \
4444
V(ERR_MESSAGE_TARGET_CONTEXT_UNAVAILABLE, Error) \
4545
V(ERR_MISSING_ARGS, TypeError) \
46-
V(ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST, TypeError) \
46+
V(ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST, TypeError) \
4747
V(ERR_MISSING_PASSPHRASE, TypeError) \
4848
V(ERR_MISSING_PLATFORM_FOR_WORKER, Error) \
4949
V(ERR_NON_CONTEXT_AWARE_DISABLED, Error) \
@@ -98,7 +98,7 @@ void OnFatalError(const char* location, const char* message);
9898
V(ERR_MESSAGE_TARGET_CONTEXT_UNAVAILABLE, \
9999
"A message object could not be deserialized successfully in the target " \
100100
"vm.Context") \
101-
V(ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST, \
101+
V(ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST, \
102102
"Object that needs transfer was found in message but not listed " \
103103
"in transferList") \
104104
V(ERR_MISSING_PLATFORM_FOR_WORKER, \

src/node_messaging.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,7 @@ class SerializerDelegate : public ValueSerializer::Delegate {
354354
ThrowDataCloneError(env_->clone_unsupported_type_str());
355355
return Nothing<bool>();
356356
} else if (mode == BaseObject::TransferMode::kTransferable) {
357-
// TODO(addaleax): This message code is too specific. Fix that in a
358-
// semver-major follow-up.
359-
THROW_ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST(env_);
357+
THROW_ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST(env_);
360358
return Nothing<bool>();
361359
}
362360

test/parallel/test-worker-message-port-transfer-filehandle.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ const { once } = require('events');
1414
assert.throws(() => {
1515
port1.postMessage(fh);
1616
}, {
17-
// See the TODO about error code in node_messaging.cc.
18-
code: 'ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST'
17+
code: 'ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST'
1918
});
2019

2120
// Check that transferring FileHandle instances works.

test/parallel/test-worker-workerdata-messageport.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const meowScript = () => 'meow';
5454
workerData,
5555
transferList: []
5656
}), {
57-
code: 'ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST',
57+
code: 'ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST',
5858
message: 'Object that needs transfer was found in message but not ' +
5959
'listed in transferList'
6060
});

0 commit comments

Comments
 (0)