From b778b5561925b9217347cc5c5b0ba077c2417fd2 Mon Sep 17 00:00:00 2001 From: Antoine Kingue Date: Fri, 11 Aug 2023 22:11:51 +0200 Subject: [PATCH] :sparkles: add anti process exit --- .changeset/yellow-queens-chew.md | 5 +++++ packages/dixt/src/index.ts | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 .changeset/yellow-queens-chew.md diff --git a/.changeset/yellow-queens-chew.md b/.changeset/yellow-queens-chew.md new file mode 100644 index 0000000..622c53e --- /dev/null +++ b/.changeset/yellow-queens-chew.md @@ -0,0 +1,5 @@ +--- +"dixt": patch +--- + +Add anti process exit diff --git a/packages/dixt/src/index.ts b/packages/dixt/src/index.ts index c8e05c2..790175e 100644 --- a/packages/dixt/src/index.ts +++ b/packages/dixt/src/index.ts @@ -3,6 +3,7 @@ import dotenv from "dotenv-flow"; import EventEmiter from "events"; import { merge } from "lodash"; import mongoose, { Mongoose } from "mongoose"; +import process from "process"; import { DixtClient, DixtSlashCommandBuilder } from "./types"; import Log from "./utils/log"; @@ -135,6 +136,18 @@ class dixt { } } +process.on("unhandledRejection", async (reason, promise) => { + Log.error("unhandled promise rejection", promise, "reason:", reason); +}); + +process.on("uncaughtException", async (error) => { + Log.error("uncaught exception", error); +}); + +process.on("uncaughtExceptionMonitor", async (error, origin) => { + Log.error("uncaught exception monitor", error, "origin:", origin); +}); + export { merge }; export { default as capitalize } from "./utils/capitalize"; export * from "./utils/discord";