Dawson
ZZod
•Created by Dawson on 12/18/2024 in #questions
Dawson - Can someone sanity check this for me? ...
all that and I need to use
superRefine
anyway as that's the only way I can abort early 😩 https://github.com/colinhacks/zod/issues/388427 replies
ZZod
•Created by Dawson on 12/18/2024 in #questions
Dawson - Can someone sanity check this for me? ...
found the culprit! the way we set up otel, specifically with zone.js, is screwing with the promise prototype for async function returns – removing the context manager line fixes the issue:
- https://github.com/open-telemetry/opentelemetry-js/issues/3030
- https://github.com/angular/angular/issues/51328#issuecomment-1688604566
otel's ZoneContextManager seems to not support es2017+ from what I'm reading
27 replies
ZZod
•Created by Dawson on 12/18/2024 in #questions
Dawson - Can someone sanity check this for me? ...
the
instanceof Promise
check is apparently sometimes faulty depending on transpilation stuff or if we're using a custom library for promises – not sure what it is for me, but it seems to be the case that I'm not using a native promise.
regardless, would it be more helpful for zod to simply check whether the result is "thenable"? as it's not doing anything more sophisticated under the hood, and that's more in line with the Promises/A+ spec: https://promisesaplus.com/#point-53
I can get a small PR up to show what I mean if that's an option27 replies
ZZod
•Created by Dawson on 12/18/2024 in #questions
Dawson - Can someone sanity check this for me? ...
I'll update here as I find things out, but at a certain point I'll need to move on just use
superRefine
instead :sadkragg:27 replies
ZZod
•Created by Dawson on 12/18/2024 in #questions
Dawson - Can someone sanity check this for me? ...
I tracked down the mismatch to this condition in the
refine
logic: https://github.com/colinhacks/zod/blob/f7ad26147ba291cb3fb257545972a8e00e767470/src/types.ts#L381C45-L381C70
with this code, my project logs false
in devtools but everywhere else it seems to log true
(repl, codesandbox, etc.):
27 replies
ZZod
•Created by Dawson on 12/18/2024 in #questions
Dawson - Can someone sanity check this for me? ...
I use RHF elsewhere but I've been testing this outside of that usage – I'll see if I can get a barebones react repro up somewhere
27 replies
ZZod
•Created by Dawson on 12/18/2024 in #questions
Dawson - Can someone sanity check this for me? ...
some notes:
- the issue happens whether the statement is executed in a react component/hook body or at the file top-level
- I'm running the node REPL with
yarn node
so it should be using the same zod version
- I'm running vite in dev mode with HMR and all that, so I'll try a production build and see what happens27 replies
ZZod
•Created by Dawson on 12/18/2024 in #questions
Dawson - Can someone sanity check this for me? ...
caution: strange behavior ahead 😅
I get expected behavior in the node REPL:
but running the exact same code in my vite + react project I get the incorrect log in the devtools console:
so seemingly not an issue with zod but maybe with vite or react with zod
27 replies
ZZod
•Created by Dawson on 12/18/2024 in #questions
Dawson - Can someone sanity check this for me? ...
ok so it's working with
superRefine
, so maybe I'll use that – am I using refine
wrong or is this a bug?
logs {success: false}
27 replies
ZZod
•Created by Dawson on 12/18/2024 in #questions
Dawson - Can someone sanity check this for me? ...
simply removing the
async
keyword gives an expected result, but I obviously can't do that if I need an async call to perform the validation27 replies