src: fix unhandled error in structuredClone

Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/54764
Fixes: https://github.com/nodejs/node/issues/54602
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Daeyeon Jeong 2024-09-08 08:05:00 +09:00 committed by GitHub
parent 46c6f8ce26
commit eab9729d16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -567,7 +567,9 @@ Maybe<bool> 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<bool>();
}
}
if (delegate.AddNestedHostObjects().IsNothing())

View File

@ -26,3 +26,6 @@ assert.strictEqual(structuredClone(undefined, { }), undefined);
assert.deepStrictEqual(cloned, {});
}
const blob = new Blob();
assert.throws(() => structuredClone(blob, { transfer: [blob] }), { name: 'DataCloneError' });