Skip to content

Commit 5b1dbf0

Browse files
committed
chore(supportthreads): add logging for waiting for initial thread message
1 parent 0a0e4d4 commit 5b1dbf0

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/index.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,21 @@ client.on(GatewayDispatchEvents.ThreadCreate, async ({ data: channel }) => {
128128
return;
129129
}
130130

131+
const receivedAt = Date.now();
132+
131133
// Messages can only be sent after the thread starter message has arrived.
132134
// This can take substantial amounts of time after thread create in the case of large attachments
133-
const collected = await waitForMessage(channel.id, 10_000).catch(() => null);
135+
const collected = await waitForMessage(channel.id, 10_000).catch((error: Error) => {
136+
const failedAt = Date.now();
137+
const failedAfterSeconds = (failedAt - receivedAt) / 1_000;
138+
logger.info(
139+
error,
140+
`Failed while waiting for a message in channel ${channel.id}: ${
141+
error.message
142+
}, failed after: ${failedAfterSeconds.toFixed(2)}s`,
143+
);
144+
});
145+
134146
if (!collected) {
135147
return;
136148
}

0 commit comments

Comments
 (0)