使用 fetch 时如何确定超时?

How will timeout be determined when using fetch?

我看了几个问题和答案,发现我们不能为获取请求设置超时。在那种情况下,什么将决定获取请求的超时时间?如果服务器从不响应提取请求怎么办?是否期望获取请求永远存在直到服务器响应或客户端终止它?

没有特定于 Fetch API. As a matter of fact, it's not even mentioned in the specification. However, what you should think about is the browser in which you're using. That may play a role in how long a given request is allowed to live (see this)

的幻数

如果您需要强制超时,那么我建议将您的 fetch 调用包装在自定义超时包装器中(示例