Skip to content

Commit

Permalink
Merge pull request #199 from AthennaIO/develop
Browse files Browse the repository at this point in the history
fix(ignite): register only one uncaught ehandler
  • Loading branch information
jlenon7 authored Dec 10, 2023
2 parents 1f4cd39 + ef0ab01 commit 0ae1b64
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/core",
"version": "4.14.0",
"version": "4.14.1",
"description": "The plug and play Node.js framework.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down
11 changes: 7 additions & 4 deletions src/ignite/Ignite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,14 @@ export class Ignite {
* ```
*/
public setUncaughtExceptionHandler(): void {
/**
* Remove listeners registered more then once by
* Ignite class.
*/
if (process.listeners('uncaughtException').length) {
process.removeListener(
'uncaughtException',
this.options.uncaughtExceptionHandler
)
process.listeners('uncaughtException').forEach(l => {
process.removeListener('uncaughtException', l)
})
}

process.on('uncaughtException', this.options.uncaughtExceptionHandler)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/ignite/IgniteTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default class IgniteTest {

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
assert.lengthOf(process?._events?.uncaughtException, 3)
assert.lengthOf(process?._events?.uncaughtException, 2)
}

@Test()
Expand Down

0 comments on commit 0ae1b64

Please sign in to comment.