Skip to content

Commit eab9729

Browse files
authored
src: fix unhandled error in structuredClone
Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com> PR-URL: #54764 Fixes: #54602 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 46c6f8c commit eab9729

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎src/node_messaging.cc‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,9 @@ Maybe<bool> Message::Serialize(Environment* env,
567567
if (host_object &&
568568
host_object->GetTransferMode() == TransferMode::kTransferable) {
569569
delegate.AddHostObject(host_object);
570-
continue;
570+
} else {
571+
ThrowDataCloneException(context, env->clone_untransferable_str());
572+
return Nothing<bool>();
571573
}
572574
}
573575
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)