Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
fix(errors): add exception handlers for uncaughtExceptions, SIGTERM a…
Browse files Browse the repository at this point in the history
…nd SIGINT

This should help avoid the service crashing when unexpected errors occur
dtfiedler committed Jul 2, 2024
1 parent c6cb5a9 commit bb66f5b
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/system.ts
Original file line number Diff line number Diff line change
@@ -15,21 +15,17 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {
ANT,
ANTRecord,
AoIORead,
IO,
ProcessId,
isLeasedArNSRecord,
} from '@ar.io/sdk/node';
import { ANT, ANTRecord, AoIORead, IO, ProcessId, isLeasedArNSRecord } from '@ar.io/sdk/node';

Check failure on line 18 in src/system.ts

GitHub Actions / build (lint:check)

Replace `·ANT,·ANTRecord,·AoIORead,·IO,·ProcessId,·isLeasedArNSRecord·` with `⏎··ANT,⏎··ANTRecord,⏎··AoIORead,⏎··IO,⏎··ProcessId,⏎··isLeasedArNSRecord,⏎`
import pLimit from 'p-limit';

Check failure on line 19 in src/system.ts

GitHub Actions / build (lint:check)

Delete `⏎⏎`



import { LmdbKVStore } from './cache/lmdb-kv-store.js';
import * as config from './config.js';
import log from './log.js';
import { ArNSResolvedData } from './types.js';

Check failure on line 26 in src/system.ts

GitHub Actions / build (lint:check)

Delete `⏎`


let lastEvaluationTimestamp: number | undefined;
let evaluationInProgress = false;
export const getLastEvaluatedTimestamp = () => lastEvaluationTimestamp;
@@ -203,3 +199,23 @@ export async function evaluateArNSNames() {

return;
}

Check failure on line 201 in src/system.ts

GitHub Actions / build (lint:check)

Delete `⏎`


// Exception Handlers

process.on('uncaughtException', (error: any) => {
log.error('Uncaught exception!', {
error: error?.message,
stack: error?.stack,
});
});

process.on('SIGTERM', () => {
log.info('SIGTERM received, exiting...');
process.exit(0);
});

process.on('SIGINT', () => {
log.info('SIGINT received, exiting...');
process.exit(0);
});

0 comments on commit bb66f5b

Please sign in to comment.