worker: use DataCloneError for unknown native objects · nodejs/node@d7641d8 · GitHub
Skip to content

Commit d7641d8

Browse files
addaleaxBridgeAR
authored andcommitted
worker: use DataCloneError for unknown native objects
This aligns the behaviour better with the web. PR-URL: #28025 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
1 parent 5fc4e48 commit d7641d8

5 files changed

Lines changed: 49 additions & 9 deletions

File tree

doc/api/errors.md

Lines changed: 10 additions & 6 deletions

src/env.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ constexpr size_t kFsStatsBufferLength = kFsStatsFieldsNumber * 2;
158158
V(change_string, "change") \
159159
V(channel_string, "channel") \
160160
V(chunks_sent_since_last_write_string, "chunksSentSinceLastWrite") \
161+
V(clone_unsupported_type_str, "Cannot transfer object of unsupported type.") \
161162
V(code_string, "code") \
162163
V(commonjs_string, "commonjs") \
163164
V(config_string, "config") \

src/node_errors.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ void FatalException(v8::Isolate* isolate,
5454
V(ERR_BUFFER_CONTEXT_NOT_AVAILABLE, Error) \
5555
V(ERR_BUFFER_OUT_OF_BOUNDS, RangeError) \
5656
V(ERR_BUFFER_TOO_LARGE, Error) \
57-
V(ERR_CANNOT_TRANSFER_OBJECT, TypeError) \
5857
V(ERR_CONSTRUCT_CALL_REQUIRED, Error) \
5958
V(ERR_INVALID_ARG_VALUE, TypeError) \
6059
V(ERR_INVALID_ARG_TYPE, TypeError) \
@@ -100,7 +99,6 @@ void FatalException(v8::Isolate* isolate,
10099
#define PREDEFINED_ERROR_MESSAGES(V) \
101100
V(ERR_BUFFER_CONTEXT_NOT_AVAILABLE, \
102101
"Buffer is not available for the current Context") \
103-
V(ERR_CANNOT_TRANSFER_OBJECT, "Cannot transfer object of unsupported type")\
104102
V(ERR_CONSTRUCT_CALL_REQUIRED, "Cannot call constructor without `new`") \
105103
V(ERR_INVALID_TRANSFER_OBJECT, "Found invalid object in transferList") \
106104
V(ERR_MEMORY_ALLOCATION_FAILED, "Failed to allocate memory") \

src/node_messaging.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class SerializerDelegate : public ValueSerializer::Delegate {
232232
return WriteMessagePort(Unwrap<MessagePort>(object));
233233
}
234234

235-
THROW_ERR_CANNOT_TRANSFER_OBJECT(env_);
235+
ThrowDataCloneError(env_->clone_unsupported_type_str());
236236
return Nothing<bool>();
237237
}
238238

Lines changed: 37 additions & 0 deletions

0 commit comments

Comments
 (0)