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,7 +120,8 @@ export class ClearcutLogger {
|
||||||
reject(e);
|
reject(e);
|
||||||
});
|
});
|
||||||
req.end(body);
|
req.end(body);
|
||||||
}).then((buf: Buffer) => {
|
})
|
||||||
|
.then((buf: Buffer) => {
|
||||||
try {
|
try {
|
||||||
this.last_flush_time = Date.now();
|
this.last_flush_time = Date.now();
|
||||||
return this.decodeLogResponse(buf) || {};
|
return this.decodeLogResponse(buf) || {};
|
||||||
|
@ -128,6 +129,12 @@ export class ClearcutLogger {
|
||||||
console.error('Error flushing log events:', error);
|
console.error('Error flushing log events:', error);
|
||||||
return {};
|
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 {};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue