Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
Process.exit() after http request

I want to send push notification with http request and then call process.exit() function but it doesn't work, process stops but push notification doesn't send. It works if i remove the process.exit function. Here is the code:

await page
.waitForSelector(".guest", { timeout: 5000 })
.then(async () => {
  console.log("Not logged in, exiting");
  await pushNotification("App has stopped, probably session expired.");
  process.exit();
})

async function pushNotification(msg) {
  var options = {
    method: "POST",
    url: "url",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      to: "",
      title: "",
      body: ``,
    }),
  };
  request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
  });
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!