Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support structuredClone #177

Closed
SimenB opened this issue Nov 23, 2021 · 3 comments
Closed

Support structuredClone #177

SimenB opened this issue Nov 23, 2021 · 3 comments

Comments

@SimenB
Copy link
Collaborator

SimenB commented Nov 23, 2021

Ships in Node 17

https://nodejs.org/api/globals.html#structuredclonevalue-options
https://developer.mozilla.org/en-US/docs/Web/API/structuredClone

it is also used by e.g. worker_threads, which ships from node 10

const envalid = require('envalid');

const config = envalid.cleanEnv({ HELLO: 'foobar' }, { HELLO: envalid.str() });

structuredClone(config);

throws

Uncaught:
DOMException [DataCloneError]: #<Object> could not be cloned.
    at structuredClone (node:internal/structured_clone:15:17)
@af
Copy link
Owner

af commented Nov 28, 2021

Good idea, I hadn't seen this API yet. Any idea how to opt into it? I'm guessing it's the proxy middleware that's problematic here

@SimenB
Copy link
Collaborator Author

SimenB commented Dec 9, 2021

I don't know if it's possible actually. Seems to be undiscoverable by spec: https://bugzilla.mozilla.org/show_bug.cgi?id=1269327

Should at least add a note in the readme to warn users

@af
Copy link
Owner

af commented Dec 12, 2021

Added a Readme note in a new faq section: https://github.com/af/envalid#faq

@af af closed this as completed Dec 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants