From 0daa1febc42dee28ac10c854a95c1afc5d848d9f Mon Sep 17 00:00:00 2001 From: jlenon7 Date: Sun, 15 Feb 2026 15:23:39 -0300 Subject: [PATCH 1/2] fix(ignite): add option to dont exit on errors --- .github/workflows/cd.yml | 6 +++-- package-lock.json | 4 +-- package.json | 2 +- src/ignite/Ignite.ts | 50 +++++++++++++++++++++++++++++++++----- src/types/IgniteOptions.ts | 7 ++++++ 5 files changed, 58 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index c38be3d..e065c86 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -8,6 +8,9 @@ on: jobs: build: runs-on: ubuntu-latest + permissions: + contents: write + id-token: write steps: - name: Checkout uses: actions/checkout@v2 @@ -32,8 +35,7 @@ jobs: id: release - name: Publish to NPM Registry - run: cd build && npm publish --access public + run: cd build && npm publish --provenance --access public if: steps.release.outputs.released == 'true' env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} name: Deploy diff --git a/package-lock.json b/package-lock.json index 5447ec0..34da104 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@athenna/core", - "version": "5.36.0", + "version": "5.37.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@athenna/core", - "version": "5.36.0", + "version": "5.37.0", "license": "MIT", "dependencies": { "pretty-repl": "^3.1.2", diff --git a/package.json b/package.json index 7323d11..2f529d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@athenna/core", - "version": "5.36.0", + "version": "5.37.0", "description": "One foundation for multiple applications.", "license": "MIT", "author": "João Lenon ", diff --git a/src/ignite/Ignite.ts b/src/ignite/Ignite.ts index f175e39..ee38bed 100644 --- a/src/ignite/Ignite.ts +++ b/src/ignite/Ignite.ts @@ -87,6 +87,7 @@ export class Ignite extends Macroable { bootLogs: true, shutdownLogs: true, environments: [], + exitOnError: true, loadConfigSafe: true, athennaRcPath: './.athennarc.json', uncaughtExceptionHandler: this.handleError @@ -528,25 +529,62 @@ export class Ignite extends Macroable { if (process.versions.bun || (!Is.Error(error) && !Is.Exception(error))) { console.error(error) - /** - * Return is needed only for testing purposes. - */ - return process.exit(1) + return this.safeExit(1) } if (!Is.Exception(error)) { error = error.toAthennaException() } + error.details.push({ isUncaughtError: false }) + if (Config.is('app.logger.prettifyException', true)) { await Log.channelOrVanilla('exception').fatal(await error.prettify()) - process.exit(1) + return this.safeExit(1) } await Log.channelOrVanilla('exception').fatal(error) - process.exit(1) + return this.safeExit(1) + } + + /** + * Handle an uncaught error turning it pretty and logging as fatal. + */ + public async handleUncaughtError(error: any) { + if (process.versions.bun || (!Is.Error(error) && !Is.Exception(error))) { + console.error(error) + + return this.safeExit(1) + } + + if (!Is.Exception(error)) { + error = error.toAthennaException() + } + + error.details.push({ isUncaughtError: true }) + + if (Config.is('app.logger.prettifyException', true)) { + await Log.channelOrVanilla('exception').fatal(await error.prettify()) + + return this.safeExit(1) + } + + await Log.channelOrVanilla('exception').fatal(error) + + return this.safeExit(1) + } + + /** + * Exit the application only if the exitOnError option is true. + */ + private safeExit(code: number): void { + if (!this.options.exitOnError) { + return + } + + process.exit(code) } /** diff --git a/src/types/IgniteOptions.ts b/src/types/IgniteOptions.ts index 7921dd6..eb00ef2 100644 --- a/src/types/IgniteOptions.ts +++ b/src/types/IgniteOptions.ts @@ -8,6 +8,13 @@ */ export type IgniteOptions = { + /** + * Exit the application if an error occurs. + * + * @default true + */ + exitOnError?: boolean + /** * Show boot logs of the application. If this option is true, Athenna * will log operations that are being executed to boot your application. From 4c2923de8e133b9fe4d5eae4dbdee1b2724e9993 Mon Sep 17 00:00:00 2001 From: jlenon7 Date: Sun, 15 Feb 2026 15:24:43 -0300 Subject: [PATCH 2/2] fix(ignite): add option to dont exit on errors --- src/ignite/Ignite.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ignite/Ignite.ts b/src/ignite/Ignite.ts index ee38bed..dfa2bf7 100644 --- a/src/ignite/Ignite.ts +++ b/src/ignite/Ignite.ts @@ -90,7 +90,7 @@ export class Ignite extends Macroable { exitOnError: true, loadConfigSafe: true, athennaRcPath: './.athennarc.json', - uncaughtExceptionHandler: this.handleError + uncaughtExceptionHandler: this.handleUncaughtError }) this.setUncaughtExceptionHandler() @@ -562,7 +562,7 @@ export class Ignite extends Macroable { if (!Is.Exception(error)) { error = error.toAthennaException() } - + error.details.push({ isUncaughtError: true }) if (Config.is('app.logger.prettifyException', true)) { @@ -575,7 +575,7 @@ export class Ignite extends Macroable { return this.safeExit(1) } - + /** * Exit the application only if the exitOnError option is true. */