Skip to content

Commit e88f2e5

Browse files
committed
Clearer warning comment about structuredClone
1 parent a144119 commit e88f2e5

File tree

1 file changed

+12
-3
lines changed
  • libs/execution/src/lib/types/io-types

1 file changed

+12
-3
lines changed

libs/execution/src/lib/types/io-types/table.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,21 @@ export class TableColumn<
3333
clone(): TableColumn<T> {
3434
const cloned: (T | InternalErrorValueRepresentation)[] = [];
3535
for (const value of this.values) {
36+
// WARNING: structuredClone has unintuitive behavior for Error subclasses.
37+
//
38+
// structuredClone replaces our custom Error's `name` field with
39+
// `"Error"`, which leads to future type checks failing, even though they
40+
// should not.
41+
//
42+
// TODO: Decide whether to implement a custom clone for
43+
// InternalValidValueRepresentation. This may require disabling nested
44+
// arrays.
45+
//
46+
// More information:
47+
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types
3648
if (ERROR_TYPEGUARD(value)) {
3749
cloned.push(value.clone());
3850
} else {
39-
// WARNING: structuredClone does not support all types!
40-
// See
41-
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types
4251
cloned.push(structuredClone(value));
4352
}
4453
}

0 commit comments

Comments
 (0)