Express Static network requests stuck on "pending"

Viewed 602

This has been working for months, I don't think I've changed anything, but with express.static, browsers show "pending" infinitely.

Here's the code:

  const app = express();
  app.use('/', express.static(
    path.resolve('./build/web'),
    { dotfiles: 'allow' },
  ));

Here's a screenshot of Chrome's network tab:

enter image description here

Only main.js has this issue. If I open the file directly, it works. This also occurs in Firefox, so I suspect it's a Node/Express issue. I have adblockers turned off.

I ran DEBUG=* node server.js and the output is:

[0] [1] Thu, 27 Aug 2020 07:02:15 GMT send stat "/path/build/web/post/101"
[0] [1] /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router dispatching GET /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router query  : /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router expressInit  : /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router jsonParser  : /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT body-parser:json skip empty body
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router urlencodedParser  : /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT body-parser:urlencoded skip empty body
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router cookieParser  : /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router corsMiddleware  : /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router trim prefix (/js/main.js) from url /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router <anonymous> /js/main.js : /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router serveStatic  : /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT send stat "/path/build/web/js/main.js"
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT send pipe "/path/build/web/js/main.js"
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT send accept ranges
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT send cache-control public, max-age=0
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT send modified Thu, 27 Aug 2020 06:50:21 GMT
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT send etag W/"180a43-1742eae7e13"
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT send content-type application/javascript
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router dispatching GET /css/main.css?v=223

This output looks normal to me.

I tried:

  • clearing cache
  • incognito
  • closing/re-opening Chrome devtools
  • closing/re-opening Chrome
  • restarting the server

After several attempts with the above, the issue goes away for a few hours, but I don't think any particular action consistently fixes the issue.

Any ideas what might be the culprit?

1 Answers

I encountered the same issue on node v14.8.0 and v14.9.0 with the latest published version of Express and the latest code on their master branch. Using v12.16.2 it works again.

Related