fix(provision): publish default stall in background to avoid blocking signup (#7) #8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix-7-publish-stall-async"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Closes #7.
provision_merchantwas inline-awaitingsign_and_send_to_nostrfor the default stall publish; the underlyingnostr_client.publish_nostr_eventhas no per-relay timeout, so an unreachable relay set pinned the uvicorn worker onPOST /auth/registerforever (since this code runs inside lnbits's eager default-merchant hook from aiolabs/lnbits#46).Schedule the publish via
asyncio.create_taskso signup returns immediately. The background task wraps the publish inasyncio.wait_forwith a 30 s cap so a permanently-unreachable relay set doesn't pin an asyncio task for the lifetime of the process; on timeout the stall'sevent_idsimply stays NULL until a later republish lands it (existing webapp-self-heal / republish behavior already handles that).The publish was already documented as "Non-fatal on failure" in the existing comment, so fire-and-forget matches the original intent — the inline await was a structural mistake, not a deliberate hard-dependency.
Test plan
Verified locally on the regtest dev stack:
LNBITS_USER_DEFAULT_EXTENSIONSincludesnostrmarketso_create_default_merchantfires on signup.POST /api/v1/auth/registerreturnsHTTP 200with a valid JWT in 2.77 s (was: indefinite).merchants+stallsrows persist with expected names; no orphaned/duplicated rows.Notes
sign_and_send_to_nostrhelper is also called from product/stall update/delete paths. Those flows want the inline-await behavior (caller wants theevent.idround-tripped). This patch only touches theprovision_merchantcall-site since that's the one in the signup-critical inline-await path.🤖 Generated with Claude Code