Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnhandledPromiseRejectionWarning #2

Closed
Kyle-Ye opened this issue Feb 16, 2020 · 8 comments
Closed

UnhandledPromiseRejectionWarning #2

Kyle-Ye opened this issue Feb 16, 2020 · 8 comments
Labels
bug Something isn't working

Comments

@Kyle-Ye
Copy link

Kyle-Ye commented Feb 16, 2020

npm node-fetch
// create config.json
node main

tried it both using config.json and set config directly. But both complain a error following.

➜  DailyReport git:(master) ✗ node main
(node:5164) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'Symbol(Request internals)' of null
    at isRequest (/Volumes/MacWorkplace/Github/DailyReport/node_modules/node-fetch/lib/index.js:1152:50)
    at new Request (/Volumes/MacWorkplace/Github/DailyReport/node_modules/node-fetch/lib/index.js:1174:8)
    at /Volumes/MacWorkplace/Github/DailyReport/node_modules/node-fetch/lib/index.js:1403:19
    at new Promise (<anonymous>)
    at fetch (/Volumes/MacWorkplace/Github/DailyReport/node_modules/node-fetch/lib/index.js:1401:9)
    at get (/Volumes/MacWorkplace/Github/DailyReport/main.js:63:49)
    at login (/Volumes/MacWorkplace/Github/DailyReport/main.js:106:11)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async fuck (/Volumes/MacWorkplace/Github/DailyReport/main.js:263:5)
(node:5164) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:5164) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@winderica
Copy link
Owner

winderica commented Feb 16, 2020

可以报一下node跟node-fetch的版本吗
应该是登录的时候出了问题,你检查一下学号跟密码是不是对的

@winderica winderica added the bug Something isn't working label Feb 16, 2020
@ManiaciaChao
Copy link

I also encountered this several times.
This may be caused by poor server performance at high concurrency, especially when it's noon because everybody has already got up.
A simple loop may help.

(async () => {
  while (true) {
    try {
      await fuck();
      console.log("Successfully fxxked!");
      break;
    } catch (err) {
      console.error(err);
      console.log("attempt to fxxk again...");
    }
  }
})();

@winderica
Copy link
Owner

我这边偶尔会报Socket hangs up的错,单步调试则不会报错,一直都以为是自己网络的问题。这样看要么是服务器性能不行,要么是做了限制。
while loop不是一个很好的解决办法,因为每一次中断的填报服务端都会产生一张无效的表单。最好是包装一下fetch,里面sleep一段时间。
但是感觉po主碰到的问题不是这个,大概是我魔改的des出了问题,总之先观望一下

@Kyle-Ye
Copy link
Author

Kyle-Ye commented Feb 17, 2020

可以报一下node跟node-fetch的版本吗
应该是登录的时候出了问题,你检查一下学号跟密码是不是对的

➜  DailyReport git:(master) ✗ node -v  
v13.8.0

// node-fetch
node-fetch@2.6.0

学号和密码没问题,我试试loop先

@Kyle-Ye
Copy link
Author

Kyle-Ye commented Feb 17, 2020

我现在也是Socket hangs up

(node:1491) UnhandledPromiseRejectionWarning: FetchError: request to https://yqtb.hust.edu.cn/infoplus/form/BKS/start failed, reason: socket hang up
    at ClientRequest.<anonymous> (/Volumes/MacWorkplace/Github/DailyReport/node_modules/node-fetch/lib/index.js:1455:11)
    at ClientRequest.emit (events.js:321:20)
    at TLSSocket.socketOnEnd (_http_client.js:463:9)
    at TLSSocket.emit (events.js:333:22)
    at endReadableNT (_stream_readable.js:1201:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:1491) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1491) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@winderica
Copy link
Owner

ok,待会改一下

winderica added a commit that referenced this issue Feb 17, 2020
@winderica
Copy link
Owner

现在应该可以了,还有问题再open

@ManiaciaChao
Copy link

仍会(看似)随机地抛出socket hang up或者TypeError: Cannot read property 'Symbol(Request internals)' of null。重复执行脚本即有几率复现。

TypeError: Cannot read property 'Symbol(Request internals)' of null说明fetch(url, opts)中参数url为null,应该是参数redirect没拿到。

不清楚后端是否限制操作频率。不过浏览器访问仍有出现请求失败的情况。我的同学今天下午几次手动填表都没成功。大概率就是服务器的问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants