mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-13 01:30:37 +08:00
Fix: track exception/rejection within single task
This commit is contained in:
parent
3107e72787
commit
78eb1f1c48
@ -1,4 +1,5 @@
|
||||
import { basename, extname } from 'node:path';
|
||||
import process from 'node:process';
|
||||
import picocolors from 'picocolors';
|
||||
|
||||
const SPAN_STATUS_START = 0;
|
||||
@ -102,6 +103,15 @@ export function task(importMetaMain: boolean, importMetaPath: string) {
|
||||
|
||||
const dummySpan = createSpan(taskName);
|
||||
if (importMetaMain) {
|
||||
process.on('uncaughtException', (error) => {
|
||||
console.error('Uncaught exception:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
process.on('unhandledRejection', (reason) => {
|
||||
console.error('Unhandled rejection:', reason);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
dummySpan.traceChildAsync('dummy', fn).finally(() => {
|
||||
dummySpan.stop();
|
||||
printTraceResult(dummySpan.traceResult);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user