@@ -4,24 +4,23 @@ const WEBHOOK_TIMEOUT_MS = 3000;
44
55// Fire-and-forget. No-op when the secret is unset. Never throws —
66// observability must not be able to break the request path.
7- // Returns the Discord message ID when available (for threading replies).
8- export async function post ( env : { DISCORD_WEBHOOK_URL ?: string } , payload : DiscordWebhookPayload ) : Promise < string | undefined > {
7+ export async function post ( env : { DISCORD_WEBHOOK_URL ?: string } , payload : DiscordWebhookPayload ) : Promise < void > {
98 const url = env . DISCORD_WEBHOOK_URL ;
10- if ( ! url ) return undefined ;
9+ if ( ! url ) return ;
1110
1211 let body : string ;
1312 try {
1413 body = JSON . stringify ( payload ) ;
1514 } catch ( e ) {
1615 console . error ( "[obs] webhook payload JSON.stringify failed:" , e ) ;
17- return undefined ;
16+ return ;
1817 }
1918
2019 const controller = new AbortController ( ) ;
2120 const timeout = setTimeout ( ( ) => controller . abort ( ) , WEBHOOK_TIMEOUT_MS ) ;
2221
2322 try {
24- const res = await fetch ( ` ${ url } ?wait=true` , {
23+ const res = await fetch ( url , {
2524 method : "POST" ,
2625 headers : { "Content-Type" : "application/json" } ,
2726 body,
@@ -32,10 +31,7 @@ export async function post(env: { DISCORD_WEBHOOK_URL?: string }, payload: Disco
3231 console . error (
3332 `[obs] webhook non-2xx: status=${ res . status } statusText=${ res . statusText } body=${ resBody . slice ( 0 , 300 ) } ` ,
3433 ) ;
35- return undefined ;
3634 }
37- const data = await res . json < { id : string } > ( ) ;
38- return data . id ;
3935 } catch ( e ) {
4036 if ( e instanceof Error && e . name === "AbortError" ) {
4137 console . error ( `[obs] webhook timed out after ${ WEBHOOK_TIMEOUT_MS } ms` ) ;
@@ -44,7 +40,6 @@ export async function post(env: { DISCORD_WEBHOOK_URL?: string }, payload: Disco
4440 const msg = e instanceof Error ? e . message : String ( e ) ;
4541 console . error ( `[obs] webhook post failed: ${ name } : ${ msg } ` ) ;
4642 }
47- return undefined ;
4843 } finally {
4944 clearTimeout ( timeout ) ;
5045 }
0 commit comments