Skip to content

Commit 5981192

Browse files
authored
remove the un-documented custom error serialization logic (#14986)
1 parent f9fd874 commit 5981192

4 files changed

Lines changed: 4 additions & 9 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove the un-documented custom error serialization logic.

packages/react-router/__tests__/vendor/turbo-stream-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ test("should encode and decode an Error", async () => {
185185
test("should encode and decode an EvalError", async () => {
186186
const input = new EvalError("foo");
187187
const output = await quickDecode(encode(input));
188-
expect(output).toEqual(input);
188+
expect(output).toEqual(new Error("foo"));
189189
});
190190

191191
test("should encode and decode array", async () => {

packages/react-router/vendor/turbo-stream-v2/flatten.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,6 @@ async function stringify(this: ThisEncode, stack: [unknown, number][]) {
172172
deferred[index] = input;
173173
} else if (input instanceof Error) {
174174
str[index] = `["${TYPE_ERROR}",${JSON.stringify(input.message)}`;
175-
if (input.name !== "Error") {
176-
str[index] += `,${JSON.stringify(input.name)}`;
177-
}
178175
str[index] += "]";
179176
} else if (Object.getPrototypeOf(input) === null) {
180177
str[index] = `["${TYPE_NULL_OBJECT}",{${partsForObj(input)}}]`;

packages/react-router/vendor/turbo-stream-v2/unflatten.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,8 @@ function hydrate(this: ThisDecode, index: number): any {
182182
}
183183
continue;
184184
case TYPE_ERROR:
185-
const [, message, errorType] = value;
186-
let error =
187-
errorType && globalObj && globalObj[errorType]
188-
? new globalObj[errorType](message)
189-
: new Error(message);
185+
const [, message] = value;
186+
let error = new Error(message);
190187
hydrated[index] = error;
191188
set(error);
192189
continue;

0 commit comments

Comments
 (0)