Javascript 当'Status = (failed)'和'Type = undefined'时Chrome遇到什么样的网络错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10125784/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 23:58:17  来源:igfitidea点击:

What kind of network error is Chrome encountering when 'Status = (failed)' and 'Type = undefined'

javascriptgoogle-chromecross-domain

提问by Stephen Ierodiaconou

Sometimes I randomly see network requests from Chrome failing with Status = '(failed)' (status code 0 from the request object in JavaScript) and the response type as 'undefined' . I cannot isolate why, my internet connection seems to be up and the same endpoint on the server works if requested from say cURL.

有时我会随机看到来自 Chrome 的网络请求失败, Status = '(failed)'(来自 JavaScript 请求对象的状态代码 0)和响应类型为 'undefined' 。我无法确定原因,如果从 cURL 请求,我的互联网连接似乎已启动并且服务器上的相同端点可以工作。

Viewing the request details does not show any more response information, only the request info.

查看请求详细信息不会显示更多响应信息,仅显示请求信息。

I thought it might be missing CORS headers, but I have verified they are there and anyway on a CORS permission problem Chrome reports the status as '(cancelled)'.

我认为它可能缺少 CORS 标头,但我已经验证它们在那里,无论如何在 CORS 权限问题上,Chrome 将状态报告为“(已取消)”。

Any thoughts? Is it just that the host is unreachable? Why does it seem that all retries from the web app also fail until the browser is restarted?

有什么想法吗?只是主机无法访问吗?为什么在浏览器重新启动之前,Web 应用程序的所有重试似乎也会失败?

(failed) request status text in Chrome inspector

Chrome 检查器中的(失败)请求状态文本

回答by rob5408

I ran into this while working on an ad serving network. It ended up being the AdBlock Plus Chrome extension blocking any assets, probably the "ad" in the path. I whitelisted my domain and it worked.

我在广告服务网络上工作时遇到了这个问题。它最终成为阻止任何资产的 AdBlock Plus Chrome 扩展程序,可能是路径中的“广告”。我将我的域列入白名单并且它起作用了。

回答by Willem D'Haeseleer

This can occur when the size in Content-Length header is larger then the actual Content being submitted, chrome considers the request "failed" since it could not retrieve the entire document.

当 Content-Length 标头中的大小大于提交的实际内容时,可能会发生这种情况,chrome 认为请求“失败”,因为它无法检索整个文档。

回答by freb

I began seeing these errors on a web page with a bad SSL certificate. I had already allowed the browser to proceed to the page, but after a while AJAX requests to the server would start failing. To fix the problem I would have to refresh the page in order to get back to the warning message so that I could accept it again and have my AJAX requests stop being blocked.

我开始在带有错误 SSL 证书的网页上看到这些错误。我已经允许浏览器继续访问该页面,但是一段时间后,对服务器的 AJAX 请求将开始失败。为了解决这个问题,我必须刷新页面才能返回警告消息,以便我可以再次接受它并停止阻止我的 AJAX 请求。

Unfortunately, in my case I haven't found the reason why Chrome forgets I want access to the domain. There is the Remember decisions to proceed through SSL errors for a specified length of timesetting in chrome://flags, but it appears to have no affect.

不幸的是,就我而言,我还没有找到 Chrome 忘记我想要访问域的原因。中有Remember decisions to proceed through SSL errors for a specified length of time设置chrome://flags,但似乎没有影响。

回答by mhenry1384

I ran into this in an ASP.NET IHttpHandler because I was calling context.Response.Close()instead of context.Response.End(). Wasn't quite closing the HTTP connection properly. It didn't cause a problem in any browsers but Chrome.

我在 ASP.NET IHttpHandler 中遇到了这个问题,因为我正在调用context.Response.Close()而不是context.Response.End(). 没有完全正确关闭 HTTP 连接。除了 Chrome 之外,它在任何浏览器中都没有引起问题。

回答by Keith Nordstrom

We had exactly this issue with an application reaching an API we control. It took a while for me to realize that slower clients were not seeing the issue, whereas faster clients (and pages with more requests) were.

我们在应用程序到达我们控制的 API 时遇到了这个问题。我花了一段时间才意识到速度较慢的客户端没有看到问题,而速度较快的客户端(以及具有更多请求的页面)却看到了。

It turned out that our HA Proxy was rate limiting requests on our frontend. Once we raised the limit from the value of 20 we had set up to something around 100, we no longer had the issue.

事实证明,我们的 HA 代理对前端的请求进行了速率限制。一旦我们将限制从我们设置的 20 值提高到 100 左右,我们就不再有问题了。

So it's possible you're getting blocked by something along the request pathway, potentially a proxy or load balancer or even a firewall.

因此,您可能会被请求路径上的某些东西阻止,可能是代理或负载平衡器,甚至是防火墙。

回答by ??????? ????

I was getting this error when a cdn was being blocked by my isp. Flushing out dns worked for me. Refer thisfor the how-to.

当我的 isp 阻止 CDN 时,我收到此错误。刷新 dns 对我有用。有关操作方法,请参阅此内容

回答by Hernaldo Gonzalez

In my case I have a Samsung laptop, and I unistalled Samsung Support Service, clear cache of Chrome and its works.

就我而言,我有一台三星笔记本电脑,我卸载了三星支持服务,清除了 Chrome 及其作品的缓存。