diff --git a/src/node_messaging.cc b/src/node_messaging.cc index 1243002a94c165..7422757fcb21bf 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -566,7 +566,9 @@ Maybe Message::Serialize(Environment* env, if (host_object && host_object->GetTransferMode() == TransferMode::kTransferable) { delegate.AddHostObject(host_object); - continue; + } else { + ThrowDataCloneException(context, env->clone_untransferable_str()); + return Nothing(); } } if (delegate.AddNestedHostObjects().IsNothing()) diff --git a/test/parallel/test-structuredClone-global.js b/test/parallel/test-structuredClone-global.js index 7a4d85b6c177f0..52a73cd2ae7c8f 100644 --- a/test/parallel/test-structuredClone-global.js +++ b/test/parallel/test-structuredClone-global.js @@ -26,3 +26,6 @@ assert.strictEqual(structuredClone(undefined, { }), undefined); assert.deepStrictEqual(cloned, {}); } + +const blob = new Blob(); +assert.throws(() => structuredClone(blob, { transfer: [blob] }), { name: 'DataCloneError' });