fix: prevent unhandled promise rejection after timeout in composio notifier
Attach a no-op .catch() to the executeAction promise so that if the timeout fires first and the action later rejects, it doesn't trigger an unhandledRejection event. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
02dad60d22
commit
0b6aee9e80
|
|
@ -209,8 +209,12 @@ export function create(config?: Record<string, unknown>): Notifier {
|
|||
const timeoutMs = 30_000;
|
||||
const timeoutSignal = AbortSignal.timeout(timeoutMs);
|
||||
|
||||
const actionPromise = composio.executeAction({ action, params });
|
||||
// Prevent unhandled rejection if the timeout fires and actionPromise later rejects
|
||||
actionPromise.catch(() => {});
|
||||
|
||||
const result = await Promise.race([
|
||||
composio.executeAction({ action, params }),
|
||||
actionPromise,
|
||||
new Promise<never>((_, reject) => {
|
||||
timeoutSignal.addEventListener("abort", () => {
|
||||
reject(new Error(`[notifier-composio] Composio API call timed out after ${timeoutMs / 1000}s`));
|
||||
|
|
|
|||
Loading…
Reference in New Issue