0

When I tried using Heroku to host my bot building went fine but an error code popped up:

2021-09-20T08:42:36.380205+00:00 heroku[worker.1]: Starting process with command `node index.js`
2021-09-20T08:42:37.212184+00:00 heroku[worker.1]: State changed from starting to up
2021-09-20T08:42:37.856773+00:00 heroku[worker.1]: Process exited with status 0
2021-09-20T08:42:37.718428+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: ReferenceError: AbortController is not defined
2021-09-20T08:42:37.718449+00:00 app[worker.1]:     at RequestHandler.execute (/app/node_modules/discord.js/src/rest/RequestHandler.js:172:15)
2021-09-20T08:42:37.718449+00:00 app[worker.1]:     at RequestHandler.execute (/app/node_modules/discord.js/src/rest/RequestHandler.js:176:19)
2021-09-20T08:42:37.718449+00:00 app[worker.1]:     at RequestHandler.push (/app/node_modules/discord.js/src/rest/RequestHandler.js:50:25)
2021-09-20T08:42:37.718452+00:00 app[worker.1]:     at async WebSocketManager.connect (/app/node_modules/discord.js/src/client/websocket/WebSocketManager.js:128:9)
2021-09-20T08:42:37.718452+00:00 app[worker.1]:     at async Client.login (/app/node_modules/discord.js/src/client/Client.js:245:7)
2021-09-20T08:42:37.722717+00:00 app[worker.1]: (Use `node --trace-warnings ...` to show where the warning was created)
2021-09-20T08:42:37.722735+00:00 app[worker.1]: (node:4) 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)
2021-09-20T08:42:37.722739+00:00 app[worker.1]: (node:4) [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.``` 
After then somebody suggested me that its a version error so I added the code: ```"engines": {
    "node": "16.7.0"
  }

and when I tried to build it, it now fails, any help?

Variable
  • 1
  • 2
  • you have an unhandled rejected promise somewhere in your code, and that terminates node with error – Nikos M. Sep 20 '21 at 08:47
  • I saw that this means that heroku is using an old node version that does not support discord.js features, are you sure it's from me? The code totally works when I run it locally. – Variable Sep 20 '21 at 08:51
  • if you cant upgrade node.js on heroku, then try using another code supported by the node.js on heroku – Nikos M. Sep 20 '21 at 08:55
  • Possibly a previous discord.js version, if that is where the problem lies – Nikos M. Sep 20 '21 at 08:56
  • 1
    You can upgrade the nodejs version in heroku by specifying `engines.node` in your package.json - see [this](https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version) – iamkneel Sep 20 '21 at 10:09

0 Answers0