fix(telemetry): handle all promise rejections in ClearcutLogger (#1557)
Co-authored-by: Scott Densmore <scottdensmore@mac.com>
This commit is contained in:
parent
31f32421a3
commit
b0cf9bcece
|
@ -120,15 +120,22 @@ export class ClearcutLogger {
|
|||
reject(e);
|
||||
});
|
||||
req.end(body);
|
||||
}).then((buf: Buffer) => {
|
||||
try {
|
||||
this.last_flush_time = Date.now();
|
||||
return this.decodeLogResponse(buf) || {};
|
||||
} catch (error: unknown) {
|
||||
})
|
||||
.then((buf: Buffer) => {
|
||||
try {
|
||||
this.last_flush_time = Date.now();
|
||||
return this.decodeLogResponse(buf) || {};
|
||||
} catch (error: unknown) {
|
||||
console.error('Error flushing log events:', error);
|
||||
return {};
|
||||
}
|
||||
})
|
||||
.catch((error: unknown) => {
|
||||
// Handle all errors to prevent unhandled promise rejections
|
||||
console.error('Error flushing log events:', error);
|
||||
// Return empty response to maintain the Promise<LogResponse> contract
|
||||
return {};
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Visible for testing. Decodes protobuf-encoded response from Clearcut server.
|
||||
|
|
Loading…
Reference in New Issue