Open kattjevfel opened 3 years ago
This is only the case for running in development mode as I've set it up so it does a more graceful death (which messes with debugging tools :v). In production more the following will happen
inaba@japan ~/Programming/Lewd/packages/discord (master*) $ npm run start
> lewd-discord@1.0.0 start /home/inaba/Programming/Lewd/packages/discord
> node ./dist/index.js
<discord.js>
Reason: Error [TOKEN_INVALID]: An invalid token was provided.
at WebSocketManager.connect (/home/inaba/Programming/Lewd/packages/discord/node_modules/discord.js/src/client/websocket/WebSocketManager.js:135:26)
at Client.login (/home/inaba/Programming/Lewd/packages/discord/node_modules/discord.js/src/client/Client.js:221:21) {
[Symbol(code)]: 'TOKEN_INVALID'
}
--------------------------
Error [TOKEN_INVALID]: An invalid token was provided.
at WebSocketManager.connect (/home/inaba/Programming/Lewd/packages/discord/node_modules/discord.js/src/client/websocket/WebSocketManager.js:135:26)
at Client.login (/home/inaba/Programming/Lewd/packages/discord/node_modules/discord.js/src/client/Client.js:221:21)
--------------------------
Promise {
<rejected> Error [TOKEN_INVALID]: An invalid token was provided.
at WebSocketManager.connect (/home/inaba/Programming/Lewd/packages/discord/node_modules/discord.js/src/client/websocket/WebSocketManager.js:135:26)
at Client.login (/home/inaba/Programming/Lewd/packages/discord/node_modules/discord.js/src/client/Client.js:221:21) {
[Symbol(code)]: 'TOKEN_INVALID'
}
}
</discord.js>
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! lewd-discord@1.0.0 start: `node ./dist/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the lewd-discord@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/inaba/.npm/_logs/2020-08-02T08_42_34_847Z-debug.log
inaba@japan ~/Programming/Lewd/packages/discord (master*) $ echo $?
1
Also TIL when node crashes because of an exception the return code is 0 :v
When encountering an error that cannot be recovered from without doing some manual fuckery or at the very least a restart of lewd, exit with a non-zero exit code to signal shit has hit the fan.
Example (permission denied for database, keeps trying anyway and service remains active):
Example 2 (Discord bot got an invalid token but still exits with code 0, marking the service as finished instead of failed):