[英]Why is Chrome waiting before every second request when using webpack-dev-server?
Can someone help me understand what is happening in the hundreds of milliseconds before the initial connection?有人可以帮助我了解初始连接前数百毫秒内发生的事情吗?
It happens on every other request only as shown.它只发生在每个其他请求上,如图所示。
The requests are POSTs made to the same ressource on localhost - against an ASP.NET Core web application.请求是针对 ASP.NET Core Web 应用程序对 localhost 上的相同资源发出的 POST。
I've looked at other similar questions and answers too, but I have seen no examples where there's just nothing before the initial connection.我也看过其他类似的问题和答案,但我没有看到在初始连接之前什么都没有的例子。 Everyone else seems to have a bar of "Stalled" or "Queueing".
其他人似乎都有一个“停顿”或“排队”的酒吧。
The "short" requests look like this: “短”请求如下所示:
Chrome version: 74.0.3729.131 (Officiel version) (64-bit) Chrome 版本:74.0.3729.131(官方版本)(64 位)
UPDATE 1 : This does not happen in Microsoft Edge.更新 1 :这在 Microsoft Edge 中不会发生。 Every request is short there.
每个请求都很短。 No wait.
不用等。
UPDATE 2 : Downloading a HAR file for a long request reveals a very long "connect" time:更新 2 :下载一个长请求的 HAR 文件显示一个很长的“连接”时间:
"timings": {
"blocked": 1.135999995024409,
"dns": 0.0030000000000000027,
"ssl": -1,
"connect": 301.202,
"send": 0.18900000000002137,
"wait": 79.29900000206612,
"receive": 3.750999996555038,
"_blocked_queueing": 0.8449999950244091
},
The short one have a connect time of -1:短的连接时间为 -1:
"timings": {
"blocked": 0.9680000060191378,
"dns": -1,
"ssl": -1,
"connect": -1,
"send": 0.091,
"wait": 50.74499999642931,
"receive": 2.582000000984408,
"_blocked_queueing": 0.8130000060191378
},
But why?但为什么?
UPDATE 3 : Turns out that this only happens when proxying through webpack-dev-server.更新 3 :事实证明,这只发生在通过 webpack-dev-server 代理时。 I'll add that tag too.
我也会添加那个标签。 Still only happens in Chrome though.
尽管如此,它仍然只发生在 Chrome 中。
UPDATE 4 : A summary of what seems to be the case right now, the pattern emerges when using:更新 4 :现在似乎是这种情况的摘要,使用时会出现该模式:
Both in NodeJS 10 and NodeJS 12. Tested on multiple machines and with Chrome in incognito mode as well.均在 NodeJS 10 和 NodeJS 12 中。在多台机器上进行了测试,并在隐身模式下使用 Chrome。
I posted this as an issue here https://github.com/webpack/webpack-dev-server/issues/1850 and a solution was found.我将其作为问题发布在这里https://github.com/webpack/webpack-dev-server/issues/1850并找到了解决方案。
Details can be found in the issue discussion, but the solution was to listen directly on IPv6 loopback address instead, like:可以在问题讨论中找到详细信息,但解决方案是直接侦听 IPv6 环回地址,例如:
const server = new WebpackDevServer(webpack(config), {
hot: true,
writeToDisk: false,
historyApiFallback: true,
contentBase: path.join(__dirname, 'src'),
proxy: [{
context: ["/api/**"],
target: "http://localhost:5000",
logLevel: 'debug'
}]
});
// Listen on ::1, details here https://github.com/webpack/webpack-dev-server/issues/1850
server.listen(3000, '::1', err => {
if (err) {
return console.log(err);
}
console.log('Listening at http://localhost:3000/');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.