Skip to content

Commit 97cbcfb

Browse files
daeyeonaduh95
authored andcommitted
src: fix unhandled error in structuredClone
Signed-off-by: Daeyeon Jeong <[email protected]> PR-URL: #54764 Fixes: #54602 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 608a611 commit 97cbcfb

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/node_messaging.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,9 @@ Maybe<bool> Message::Serialize(Environment* env,
566566
if (host_object &&
567567
host_object->GetTransferMode() == TransferMode::kTransferable) {
568568
delegate.AddHostObject(host_object);
569-
continue;
569+
} else {
570+
ThrowDataCloneException(context, env->clone_untransferable_str());
571+
return Nothing<bool>();
570572
}
571573
}
572574
if (delegate.AddNestedHostObjects().IsNothing())

test/parallel/test-structuredClone-global.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ assert.strictEqual(structuredClone(undefined, { }), undefined);
2626

2727
assert.deepStrictEqual(cloned, {});
2828
}
29+
30+
const blob = new Blob();
31+
assert.throws(() => structuredClone(blob, { transfer: [blob] }), { name: 'DataCloneError' });

0 commit comments

Comments
 (0)