Skip to content

Commit

Permalink
fix: improve error handling on uncaught exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
IamSebastianDev committed Dec 3, 2022
1 parent 6ce8b5d commit 8a80044
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/lib/Db/Flotsam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import { mkdir } from 'node:fs/promises';
import { existsSync } from 'node:fs';
import { safeAsyncAbort, __root } from '../../utils';
import { FlotsamInit, FlotsamEvent, Unsubscriber, Subscriber, Callback, ErrorHandler } from '../../types';
import { __root } from '../../utils';
import { FlotsamInit, FlotsamEvent, Unsubscriber, Subscriber, Callback, ErrorHandler, Validator } from '../../types';
import { Collection } from './Collection';
import { Loq } from './Loq';
import { Queue } from './Queue';
Expand Down Expand Up @@ -107,6 +107,12 @@ export class Flotsam {
this.log = init.log;

this.createInitialListeners();

process.on('uncaughtException', (error) => {
this.close().then(() => {
process.exit(1);
});
});
}

/**
Expand Down

0 comments on commit 8a80044

Please sign in to comment.