From 40d3a46c16415ae96467ef72a748218ab5757a3e Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 15 Jan 2024 17:56:03 -0600 Subject: [PATCH] pipeline: use fetchWorker properly for zaps, pass signal --- src/pipeline.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pipeline.ts b/src/pipeline.ts index d554d3f..10af61c 100644 --- a/src/pipeline.ts +++ b/src/pipeline.ts @@ -162,14 +162,14 @@ function processMedia({ tags, pubkey }: Event, { user }: EventData) { } /** Submit zap requests to Lightning nodes (for local users only). */ -async function submitZaps(event: Event, data: EventData) { +async function submitZaps(event: Event, data: EventData, signal = AbortSignal.timeout(5000)) { if (event.kind === 9734 && data.user) { const lnurl = event.tags.find(([name]) => name === 'lnurl')?.[1]; const amount = event.tags.find(([name]) => name === 'amount')?.[1]; if (lnurl && amount) { try { const url = lnurlDecode(lnurl); - const response = await fetchWorker(url); + const response = await fetchWorker(url, { signal }); const json = await response.json(); const result = lnurlResponseSchema.parse(json); if (result.tag === 'payRequest' && result.allowsNostr && result.nostrPubkey) { @@ -179,7 +179,7 @@ async function submitZaps(event: Event, data: EventData) { params.set('nostr', JSON.stringify(event)); params.set('lnurl', lnurl); callback.search = params.toString(); - await fetch(callback); + await fetchWorker(callback, { signal }); } } catch (e) { debug('lnurl error:', e);