1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 15:24:46 -05:00
denoland-deno/ext
Matt Mastracci 4104a674c7
fix(ext/ffi): improve error messages in FFI module (#17786)
Fixes denoland#16922.

The error messages in the `ffi` module are somewhat cryptic when passing
functions that have invalid `parameters` or `result` type strings. While
the generated serializer for the `ForeignFunction` struct correctly
outputs a correct and verbose message, the user sees a far less helpful
`data did not match any variant` message instead.

The underlying cause appears to be the fallback message in the
auto-derived deserializer for untagged enums [1] generated as a result
of `ForeignSymbol` being marked as `#[serde(untagged)]` [2]. Passing an
unexpected value for `NativeType` causes it to error out while
attempting to deserialize both enum variants -- once because it's not a
match for the `ForeignStatic` variant, and once because the
`ForeignFunction` deserializer rejects the invalid type for the
parameters/return type. This is currently open as [serde
#773](https://github.com/serde-rs/serde/issues/773), and not a trivial
exercise to fix generically.

[1]
https://github.com/serde-rs/serde/blob/v0.9.7/serde_derive/src/de.rs#L730
[2] https://github.com/denoland/deno/blob/main/ext/ffi/dlfcn.rs#L102
[3] https://github.com/serde-rs/serde/issues/773

Note that the auto-generated deserializer for untagged enums uses a
private API to buffer deserializer content that we don't have access to.
Instead, we can make use of the `serde_value` crate to buffer the
values. This can likely be removed once the official buffering API lands
(see [4] and [5]). In addition, this crate pulls in `serde_json` as a
cheap way to test that the deserializer works properly.

[4] https://github.com/serde-rs/serde/issues/741
[5] https://github.com/serde-rs/serde/pull/2348
2023-02-15 09:41:59 +05:30
..
broadcast_channel refactor: remove prefix from include_js_files & use extension name (#17683) 2023-02-07 21:09:50 +00:00
cache refactor: remove prefix from include_js_files & use extension name (#17683) 2023-02-07 21:09:50 +00:00
console fix(ext/console): Only right-align integers in console.table() (#17389) 2023-02-08 18:14:40 +09:00
crypto refactor: remove prefix from include_js_files & use extension name (#17683) 2023-02-07 21:09:50 +00:00
fetch refactor: remove prefix from include_js_files & use extension name (#17683) 2023-02-07 21:09:50 +00:00
ffi fix(ext/ffi): improve error messages in FFI module (#17786) 2023-02-15 09:41:59 +05:30
flash fix(ext/flash): Always send correct number of bytes when handling HEAD requests (#17740) 2023-02-12 16:13:05 +05:30
http perf(http): remove allocations checking upgrade and connection header values (#17727) 2023-02-12 20:51:07 +00:00
napi feat(node): stabilize Node-API (#17553) 2023-02-14 15:53:00 +01:00
net feat: add signal option to Deno.resolveDns (#17384) 2023-02-11 14:14:02 +00:00
node feat(ext/node): embed std/node into the snapshot (#17724) 2023-02-14 17:38:45 +01:00
tls chore: forward v1.30.3 release commit to main (#17677) 2023-02-07 04:15:38 +00:00
url refactor(core): change SourcePair to ExtensionFileSource (#17686) 2023-02-08 00:21:43 +01:00
web feat(ext/node): embed std/node into the snapshot (#17724) 2023-02-14 17:38:45 +01:00
webgpu fix(webgpu): use correct op for GPUDevice.createSampler (#17729) 2023-02-11 05:40:51 +00:00
webidl refactor(ext/webidl): use TypedArrayPrototypeGetSymbolToStringTag (#17602) 2023-02-09 22:45:47 +01:00
websocket fix(ext/websocket): extra ws pongs sent (#17762) 2023-02-13 14:58:32 +00:00
webstorage refactor: remove prefix from include_js_files & use extension name (#17683) 2023-02-07 21:09:50 +00:00