Skip to content

Handle DataCloneError's #223

@kungfooman

Description

@kungfooman

Sometimes information is posted "cross-context" that can't be posted.

An easy check for what can be posted is using structuredClone.

Good examples:

structuredClone([1, 2, 3]);
structuredClone(new Uint32Array([1, 2, 3]))

image

Bad examples:

structuredClone(() => {});
structuredClone(class {});

So we just get this error: Uncaught DataCloneError: Failed to execute 'structuredClone' on 'Window': class {} could not be cloned.

Errors:

image

So this usually happens when a type is typeof SomeClass... because then the value is of course the class, which can't be cloned.

Metadata

Metadata

Assignees

Labels

RuntimebugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions