Prevent "Uncaught promise" messages in the console when cancelling (some) ReadableStreams

While fixing issue 13794, I noticed that cancelling the `ReadableStream` returned by the `PDFPageProxy.streamTextContent`-method could lead to "Uncaught promise" messages in the console.[1]
Generally speaking, we don't really care about errors when *cancelling* a `ReadableStream` and it thus seems reasonable to simply suppress any output in those cases.

---
[1] Although, after that issue was fixed you'd now need to set the API-option `stopAtErrors = true` to actually trigger this.
This commit is contained in:
Jonas Jenwald 2021-07-30 14:13:02 +02:00
parent 4ad5c5d52a
commit 1df9da949e
2 changed files with 12 additions and 5 deletions

View file

@ -1802,7 +1802,11 @@ class PDFPageProxy {
return;
}
}
intentState.streamReader.cancel(new AbortException(reason?.message));
intentState.streamReader
.cancel(new AbortException(reason?.message))
.catch(() => {
// Avoid "Uncaught promise" messages in the console.
});
intentState.streamReader = null;
if (this._transport.destroyed) {