GeezerVison is showing github.com — src: fix unhandled error in structuredClone · nodejs/node@97cbcfb
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/node_messaging.cc +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -566,7 +566,9 @@ Maybe<bool> Message::Serialize(Environment* env, |
566 | 566 | if (host_object && |
567 | 567 | host_object->GetTransferMode() == TransferMode::kTransferable) { |
568 | 568 | delegate.AddHostObject(host_object); |
569 | | - continue; |
| 569 | + } else { |
| 570 | + ThrowDataCloneException(context, env->clone_untransferable_str()); |
| 571 | + return Nothing<bool>(); |
570 | 572 | } |
571 | 573 | } |
572 | 574 | if (delegate.AddNestedHostObjects().IsNothing()) |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-structuredClone-global.js +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -26,3 +26,6 @@ assert.strictEqual(structuredClone(undefined, { }), undefined); |
26 | 26 |
|
27 | 27 | assert.deepStrictEqual(cloned, {}); |
28 | 28 | } |
| 29 | + |
| 30 | +const blob = new Blob(); |
| 31 | +assert.throws(() => structuredClone(blob, { transfer: [blob] }), { name: 'DataCloneError' }); |