From c6bf07ec6d231d29149a2454d3b5135a41c6cbab Mon Sep 17 00:00:00 2001 From: Andreu Botella Date: Mon, 14 Mar 2022 19:35:15 +0100 Subject: fix(core): Don't override structured clone error messages from V8 (#13942) In the implementation of structured serialization in `Deno.core.serialize`, whenever there is a serialization error, an exception will be thrown with the message "Failed to serialize response", even though V8 provides a message to use in such cases. This change instead throws an exception with the V8-provided message, if there is one. --- cli/tests/unit/structured_clone_test.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'cli/tests/unit/structured_clone_test.ts') diff --git a/cli/tests/unit/structured_clone_test.ts b/cli/tests/unit/structured_clone_test.ts index f25276165..fdad0dba7 100644 --- a/cli/tests/unit/structured_clone_test.ts +++ b/cli/tests/unit/structured_clone_test.ts @@ -1,4 +1,4 @@ -import { assert, assertEquals } from "./test_util.ts"; +import { assert, assertEquals, assertThrows } from "./test_util.ts"; // Basic tests for the structured clone algorithm. Mainly tests TypeScript // typings. Actual functionality is tested in WPT. @@ -17,3 +17,14 @@ Deno.test("self.structuredClone", async () => { channelOriginal.port1.close(); portTransferred.close(); }); + +Deno.test("correct DataCloneError message", () => { + assertThrows( + () => { + const sab = new SharedArrayBuffer(1024); + structuredClone(sab, { transfer: [sab] }); + }, + DOMException, + "Value not transferable", + ); +}); -- cgit v1.2.3