Express Static网络请求停留在“待定"状态. [英] Express Static network requests stuck on "pending"

查看:71
本文介绍了Express Static网络请求停留在“待定"状态.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这已经工作了几个月了,我认为我没有做任何更改,但是通过 express.static ,浏览器显示"pending"(待定).无限地.

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

代码如下:

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

以下是Chrome的网络"标签的屏幕截图:

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

只有 main.js 出现此问题.如果我直接打开文件,它将起作用.在Firefox中也会发生这种情况,因此我怀疑这是Node/Express问题.我关闭了adblocker.

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.

我运行了 DEBUG = *节点server.js ,输出为:

[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.

我尝试过:

  • 清除缓存
  • 隐身
  • 关闭/重新打开Chrome devtools
  • 关闭/重新打开Chrome
  • 重新启动服务器

经过上述几次尝试后,问题消失了几个小时,但是我认为没有任何特定的措施可以持续解决问题.

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?

推荐答案

我在节点v14.8.0和v14.9.0上遇到了相同的问题,使用的是Express的最新发布版本以及其master分支上的最新代码.使用v12.16.2,它可以再次工作.

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.

这篇关于Express Static网络请求停留在“待定"状态.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆