A Chrome specific issue, where requests are getting blocked after a handful of link clicks
mnkcoder opened this issue · comments
- Operating System: MacOS
- Node Version: v18.17.0
- NPM Version: 9.6.7
- webpack Version: 5.88.2
- ${package} Version:
Expected Behavior
Link navigations should just work.
Actual Behavior
After a handful (5 or more) of navigation clicks, I am noticing that the requests are staying pending for a while, see below for a sample request header.
![Screenshot 2023-12-24 at 9 18 23 AM](https://private-user-images.githubusercontent.com/49691395/292683318-9967fcb5-2dfd-43ca-9854-392cf7cb73e7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk2NDM0MjcsIm5iZiI6MTcxOTY0MzEyNywicGF0aCI6Ii80OTY5MTM5NS8yOTI2ODMzMTgtOTk2N2ZjYjUtMmRmZC00M2NhLTk4NTQtMzkyY2Y3Y2I3M2U3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI5VDA2Mzg0N1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZmM2VhZTZjODE5MzFkYjNmNWEyNTZiNzNjZjBiYjlkNjViNDNkM2Y3ZDY2OGU1NTBkYmIyNTM4YWQzNjMxZmEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.l9gIBXyUGp0mqqYxq9M9kfjjAjCYSk2lvE27sXqMOJ8)
**Noticed that this behavior is occurring only when I am running in Chrome, all other browsers are working just fine. Also, I don't have many tabs open and aware that there are some server connection limits. This issue is occuring consistently **
Code
Here is my webpack config
import webpack from "webpack";
import path from "path";
import type { Configuration as DevServerConfiguration } from "webpack-dev-server";
import type { Configuration } from "webpack";
const devServer: DevServerConfiguration = {
port: 3000,
hot: true,
};
const webpackConfig: Configuration = {
mode: "development",
devtool: "eval",
entry: {
"test-app": [
"webpack/hot/dev-server",
"eventsource-polyfill",
"webpack-hot-middleware/client?reload=true",
"./src/client/apps/test-app/App.tsx",
],
"home-app": [
"webpack/hot/dev-server",
"eventsource-polyfill",
"webpack-hot-middleware/client?reload=true",
"./src/client/apps/home-app/App.tsx",
],
"sign-up-app": [
"webpack/hot/dev-server",
"eventsource-polyfill",
"webpack-hot-middleware/client?reload=true",
"./src/client/apps/sign-up-app/App.tsx",
],
"sign-in-app": [
"webpack/hot/dev-server",
"eventsource-polyfill",
"webpack-hot-middleware/client?reload=true",
"./src/client/apps/sign-in-app/App.tsx",
],
},
target: "web",
output: {
path: path.resolve(__dirname, "/"),
publicPath: "/",
filename: "js/[name].js",
},
devServer,
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
],
module: {
rules: [
{
// Match `.js`, `.jsx`, `.ts` or `.tsx` files
test: /\.[jt]sx?$/,
loader: 'esbuild-loader',
options: {
target: 'es2020'
}
},
{
test: /(\.css)$/,
use: ["style-loader", "css-loader"] },
{
test: /\.(png|svg|jpg|gif)$/,
use: ["url-loader" ],
},
{
test: /\.s[ac]ss$/i,
use: [
"style-loader",
"css-loader",
"sass-loader",
],
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
};
export default webpackConfig;
// additional code, HEY YO remove this block if you don't need it
How Do We Reproduce?
Create a reproduction repository please
appreciate the quick response. Let me put together a sample repo for this.
Ok, in the process of creating a sample repo I ended up finding a fix for this. I added and changed below webpack sections into my existing setup:
added this
var hotMiddlewareScript = 'webpack-hot-middleware/client?path=/__webpack_hmr&timeout=500&reload=true';
and changed my entry points code to this
entry: {
"home-app": [ "./src/client/apps/home-app/App.tsx", hotMiddlewareScript ],
"sign-up-app": [ "./src/client/apps/sign-up-app/App.tsx", hotMiddlewareScript ],
"sign-in-app": [ "./src/client/apps/sign-in-app/App.tsx", hotMiddlewareScript ]
}
Please let me know if I am doing anything unusual with this change.