Closure invoked after being dropped in `Drop` impls of `IntoStream` and `IntoAsyncRead`
This is a regression from #8, where the `Drop` impls for `IntoStream` and `IntoAsyncRead` pass a closure to `Promise::catch` that is immediately dropped (in particular, before rejection). When the promise does reject, there is an uncaught error.
```
19:58:06.628 app-7f15e89b3e1fb129.js:2383 Uncaught (in promise) Error: closure invoked recursively or after being dropped
at imports.wbg.__wbindgen_throw (app-7f15e89b3e1fb129.js:2383:15)
at app-fec6fea4ac943e1b.wasm.wasm_bindgen::throw_str::h472eba1fa5a1853e (app-7f15e89b3e1fb129_bg.wasm:0x8da16d)
at app-fec6fea4ac943e1b.wasm.<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::hebcfb59b365eeed1 (http://localhost:8080/app-7f15e89b3e1fb129_bg.wasm)
at __wbg_adapter_75 (app-7f15e89b3e1fb129.js:295:10)
at real (app-7f15e89b3e1fb129.js:204:20)
imports.wbg.__wbindgen_throw @ app-7f15e89b3e1fb129.js:2383
$wasm_bindgen::throw_str::h472eba1fa5a1853e @ app-7f15e89b3e1fb129_bg.wasm:0x8da16d
$<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::hebcfb59b365eeed1 @ app-7f15e89b3e1fb129_bg.wasm:0x749773
__wbg_adapter_75 @ app-7f15e89b3e1fb129.js:295
real @ app-7f15e89b3e1fb129.js:204
Promise.catch
imports.wbg.__wbg_catch_a279b1da46d132d8 @ app-7f15e89b3e1fb129.js:2284
$js_sys::Promise::catch::h5d113b1aa9247c07 @ app-7f15e89b3e1fb129_bg.wasm:0x791fb2
$<wasm_streams::readable::into_async_read::IntoAsyncRead as core::ops::drop::Drop>::drop::hccf764f31b5bd8d5 @ app-7f15e89b3e1fb129_bg.wasm:0x4e1ecb
$core::ptr::drop_in_place<wasm_streams::readable::into_async_read::IntoAsyncRead>::hcf9c3d4292ff50f6 @ app-7f15e89b3e1fb129_bg.wasm:0x859f38
```
The relevant lines are:
https://github.com/MattiasBuelens/wasm-streams/blob/c041860916dd38defad064f5d5ba69d0388a65cc/src/readable/into_stream.rs#L112
https://github.com/MattiasBuelens/wasm-streams/blob/c041860916dd38defad064f5d5ba69d0388a65cc/src/readable/into_async_read.rs#L140
关闭于 2024-09-27 0 条评论