Skip to content

Commit 0a062a3

Browse files
fix(runtimes): timeout for exiting to emit logs (#602)
* fix(runtimes): timeout for exiting to emit logs * fix(runtimes): change exit() to exitCode to stop shutdown * fix(runtimes): change exit() to exitCode to stop shutdown * fix(runtimes): better wait time for process.exit * fix(runtimes): different error code * fix(runtimes): document why exit code is 5 * fix(runtimes): todo added for future work
1 parent fe33961 commit 0a062a3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

runtimes/runtimes/operational-telemetry/operational-telemetry-service.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ export class OperationalTelemetryService implements OperationalTelemetry {
7474
process.on('uncaughtException', async () => {
7575
// Telemetry signals are force flushed to their exporters on shutdown.
7676
await this.shutdownApi()
77-
process.exit(1)
77+
// exit code 5 to differentiate from truly uncaught errors (which will use exit code 1)
78+
// 2s timeout to wait for stdout/stderr buffers to clear
79+
// TODO: remove `process.exit`, set `process.exitCode = 5`, and exit gracefully from main loop
80+
setTimeout(() => {
81+
process.exit(5)
82+
}, 2000)
7883
})
7984

8085
process.on('beforeExit', async () => {

0 commit comments

Comments
 (0)