File tree Expand file tree Collapse file tree 5 files changed +49
-9
lines changed Open diff view settings
Expand file tree Collapse file tree 5 files changed +49
-9
lines changed Open diff view settings
Original file line number Diff line number Diff line change @@ -671,12 +671,6 @@ An operation outside the bounds of a `Buffer` was attempted.
671671An attempt has been made to create a ` Buffer ` larger than the maximum allowed
672672size.
673673
674- <a id =" ERR_CANNOT_TRANSFER_OBJECT " ></a >
675- ### ERR_CANNOT_TRANSFER_OBJECT
676-
677- The value passed to ` postMessage() ` contained an object that is not supported
678- for transferring.
679-
680674<a id =" ERR_CANNOT_WATCH_SIGINT " ></a >
681675### ERR_CANNOT_WATCH_SIGINT
682676
@@ -2013,6 +2007,16 @@ A module file could not be resolved while attempting a [`require()`][] or
20132007> Stability: 0 - Deprecated. These error codes are either inconsistent, or have
20142008> been removed.
20152009
2010+ <a id =" ERR_CANNOT_TRANSFER_OBJECT " ></a >
2011+ ### ERR_CANNOT_TRANSFER_OBJECT
2012+ <!--
2013+ added: v10.5.0
2014+ removed: REPLACEME
2015+ -->
2016+
2017+ The value passed to ` postMessage() ` contained an object that is not supported
2018+ for transferring.
2019+
20162020<a id =" ERR_CLOSED_MESSAGE_PORT " ></a >
20172021### ERR_CLOSED_MESSAGE_PORT
20182022<!-- YAML
Original file line number Diff line number Diff 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" ) \
Original file line number Diff line number Diff 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" ) \
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 1+ // Flags: --expose-internals
2+ 'use strict' ;
3+ const common = require ( '../common' ) ;
4+ const assert = require ( 'assert' ) ;
5+ const { MessageChannel } = require ( 'worker_threads' ) ;
6+ const { internalBinding } = require ( 'internal/test/binding' ) ;
7+
8+ // Test that passing native objects and functions to .postMessage() throws
9+ // DataCloneError exceptions.
10+
11+ {
12+ const { port1, port2 } = new MessageChannel ( ) ;
13+ port2 . once ( 'message' , common . mustNotCall ( ) ) ;
14+
15+ assert . throws ( ( ) => {
16+ port1 . postMessage ( function foo ( ) { } ) ;
17+ } , {
18+ name : 'DataCloneError' ,
19+ message : / f u n c t i o n f o o \( \) \{ \} c o u l d n o t b e c l o n e d \. $ /
20+ } ) ;
21+ port1 . close ( ) ;
22+ }
23+
24+ {
25+ const { port1, port2 } = new MessageChannel ( ) ;
26+ port2 . once ( 'message' , common . mustNotCall ( ) ) ;
27+
28+ const nativeObject = new ( internalBinding ( 'js_stream' ) . JSStream ) ( ) ;
29+
30+ assert . throws ( ( ) => {
31+ port1 . postMessage ( nativeObject ) ;
32+ } , {
33+ name : 'DataCloneError' ,
34+ message : / C a n n o t t r a n s f e r o b j e c t o f u n s u p p o r t e d t y p e \. $ /
35+ } ) ;
36+ port1 . close ( ) ;
37+ }
You can’t perform that action at this time.
0 commit comments