简体   繁体   English

如果reader.read()Promise拒绝/出错,再次使用reader.read()是否安全?

[英]If a reader.read() Promise rejects/errors, is it safe to reader.read() again?

My question concerns error handling of a reader from a ReadableStreamDefaultReader . 我的问题涉及从ReadableStreamDefaultReader处理读取器的错误。 I'm guessing that a Promise rejection from reader.read() would usually indicate a network failure for a fetch request (in which case i'm guessing that it is NOT safe to continue reading and I should just stop using that reader entirely), but perhaps there are other possible errors in which it IS safe to continue reading? 我猜想来自reader.read()的Promise拒绝通常会指示获取请求出现网络故障(在这种情况下,我猜想继续阅读并不安全,我应该完全停止使用该阅读器) ,但也许还有其他可能的错误可以让您继续阅读吗?

So in what scenarios can I continue reading after I receive a Promise rejection from reader.read() and in what scenarios should i scrap the reader entirely? 因此,在收到reader.read()的Promise拒绝后,在什么情况下可以继续阅读?在什么情况下应该完全废弃阅读器? Do I need to introspect on the type of error in order to make a decision? 我需要对错误的类型进行自省才能做出决定吗?

A stream cannot recover from an error. 流无法从错误中恢复。 If it is errored, reading from it will always return a rejected promise. 如果错误,从中读取将始终返回被拒绝的承诺。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM