UnhandledPromiseRejectionWarning随机发生

时间:2019-06-03 10:10:20

标签: javascript discord.js

因此,我是discord.js的新手,我正在尝试编写一个discord机器人。我正在使用snekfetch从以下URL检索数据:https://crystalmathlabs.com/tracker/api.php?type=comprankings&competition=19326

它可以工作,但有时会出现以下错误:

//first error from first command run        
(node:17512) UnhandledPromiseRejectionWarning: Error: 500 Internal Server Error
        at _response.transport.request.then (C:\Users\Alex\Downloads\discord-bot\node_modules\snekfetch\src\index.js:193:21)
        at process._tickCallback (internal/process/next_tick.js:68:7)
    (node:17512) 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(). (rejection id: 2)

//second error from the first command run a second time
    (node:17512) [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.
        (node:17512) UnhandledPromiseRejectionWarning: Error: 500 Internal Server Error
            at _response.transport.request.then (C:\Users\Alex\Downloads\discord-bot\node_modules\snekfetch\src\index.js:193:21)
            at process._tickCallback (internal/process/next_tick.js:68:7)
        (node:17512) 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(). (rejection id: 4)

//command run a third time, and it works            
alt_life,3286389,5520479,2234090
            dookie_milk,5570464,7617703,2047239
            man_of_hyrup,123827,2152761,2028934
            iron_to_live,551433,2095151,1543718

有人知道为什么有时会发生吗?

注意:代码运行后,我没有包括完整的输出,只是前几行

编辑:

发现错误并打印后,我收到此消息:

{ Error: 500 Internal Server Error
    at _response.transport.request.then (C:\Users\Alex\Downloads\discord-bot\node_modules\snekfetch\src\index.js:193:21)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  request: undefined,
  body: <Buffer ef bb bf 2d 34>,
  raw: <Buffer ef bb bf 2d 34>,
  ok: false,
  headers:
   [Object: null prototype] {
     ':status': 500,
     date: 'Mon, 03 Jun 2019 10:16:42 GMT',
     'content-type': 'text/html; charset=UTF-8',
     'set-cookie':
      [ '__cfduid=d6f57812d6ec549bbc54fd0f8ce59da441559557002; expires=Tue, 02-Jun-20 10:16:42 GMT; path=/; domain=.crystalmathlabs.com; HttpOnly',
        'flood=22fcd3b2889875eb86281892903980a9; expires=Thu, 04-Jul-2019 10:16:42 GMT; Max-Age=2678400; domain=crystalmathlabs.com' ],
     'strict-transport-security': 'max-age=63072000; includeSubdomains',
     'x-frame-options': 'DENY',
     'x-content-type-options': 'nosniff',
     'access-control-allow-origin': '*',
     'expect-ct':
      'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
     server: 'cloudflare',
     'cf-ray': '4e10e9c48f7b3621-MAN' },
  statusCode: 500,
  statusText: 'Internal Server Error' }

0 个答案:

没有答案