Open rotu opened 1 year ago
This does not seem to trigger a unhandledrejection
handler, which is puzzling. Aha! it looks like it's because after rejecting the promise, we mark that promise as handled. But the V8 debugger doesn't get this memo. https://github.com/denoland/deno/blob/772201449713fbefad6c42b9ce545a5bb2d7499b/ext/web/06_streams.js#L4208-L4218
Seems to have been caused by https://github.com/denoland/deno/pull/9103
Seems closely related to: https://github.com/whatwg/streams/issues/547 https://bugs.chromium.org/p/chromium/issues/detail?id=654701 https://bugzilla.mozilla.org/show_bug.cgi?id=1561911
Resolving may be as simple as moving setPromiseIsHandledToTrue
before the calls to Deferred.reject
or right after the Deferred
is constructed.
Though that still seems only partial. The debugger treats that as a caught exception, whereas I'd expect normal pipe closure to not create an exception at all.
The following code runs fine without a debugger attached, but if the Node debugger is attached (via either VSCode or Google Chrome), and "pause on uncaught exceptions" is enabled, then the debugger trips with the error message "TypeError: The writer has already been released."
deno run --inspect-wait --allow-all ./repro.ts
deno --version deno 1.32.1 (release, aarch64-apple-darwin) v8 11.2.214.9 typescript 5.0.2