0

I would like to launch my function but when the code returns an error 503 responds to the process exit

however the function does not restart you know why?

process.on ('unhandledRejection', async (reason, p) => {
  console.error ('Unhandled Rejection at: Promise', p, 'reason:', reason);
    run();
    if(nodeStatusCodes[503]){
  process.exit();
  }

  });
``````````````````````````````
x_zone web
  • 25
  • 4
  • The question is a bit hard to follow. What is `nodeStatusCodes` and from what function are you getting a 503 error that is unhandled? – Cody G May 07 '21 at 02:48
  • https://reposhub.com/sindresorhus-node-status-codes-nodejs-polyfills.html this is nodestatutscode I would like if he sees the code 503 for example that the process closes otherwise that the function is restarted automatically when I put the if status code 503 then process.exit but the concern that I have the function run does not restart – x_zone web May 07 '21 at 03:26
  • in fact simply if it returns the error 503 response from the website then the program closes otherwise it restarts each time when it gets an unhandledRejection error – x_zone web May 07 '21 at 03:28
  • That webpage says: this package is no longer relevant. To get more help it might be helpful if you post a simple program that returns the 503 error. – Cody G May 07 '21 at 03:45
  • in fact it detects the 503 error of the response I have no problem with its but the program does not restart this to say my script is in the function run but it does not restart however when the program finds the web 503 response then he directly exits the procedure – x_zone web May 07 '21 at 04:15
  • and in fact when I remove this part of the code if (nodeStatusCodes [503]) { process.exit (); } the program is relaunched – x_zone web May 07 '21 at 04:18
  • Perhaps `nodeStatusCodes[503]` is always `true` --- try setting a debug point on `process.exit()` and see what the value is. – Cody G May 07 '21 at 04:23
  • hello i have try to debug with this – x_zone web May 08 '21 at 21:48
  • https://stackoverflow.com/questions/67452491/my-xhr-status-return-allways-200-however-in-my-condition-if-it-does-not-take-it – x_zone web May 08 '21 at 21:55
  • I changed a little I found its more practical for me – x_zone web May 08 '21 at 21:56
  • my probleme its resolve thanks a lot :D – x_zone web May 08 '21 at 22:46

0 Answers0