Skip to content

Batch resource probes in register-origin to avoid transaction timeouts#683

Open
shafu0x wants to merge 4 commits intomainfrom
shafu/batch-register-origin
Open

Batch resource probes in register-origin to avoid transaction timeouts#683
shafu0x wants to merge 4 commits intomainfrom
shafu/batch-register-origin

Conversation

@shafu0x
Copy link
Copy Markdown
Contributor

@shafu0x shafu0x commented Mar 4, 2026

Summary

  • The register-origin endpoint fires all resource probes concurrently via a single Promise.allSettled. For origins with many resources (e.g. stablecrypto.dev with 105 endpoints), this opens 105+ concurrent DB transactions that saturate the connection pool. Under repeated load, transactions time out waiting for connections — Unable to start a transaction in the given time.
  • Replaced the single Promise.allSettled with a batched for-loop processing 10 resources at a time. Extracted the probe logic into a standalone probeAndRegister function for cleaner typing and readability.

Testing

Tested against production (old code) — 5 sequential runs on stablecrypto.dev:

  • Run 1: 105/105
  • Run 2: 105/105
  • Run 3: 21/105 (84 failed — transaction timeouts)
  • Run 4: 105/105
  • Run 5: 25/105 (80 failed — transaction timeouts)

Tested against preview branch (batched code) — 10 sequential runs on stablecrypto.dev:

  • All 10 runs: 105/105, 0 failures

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
x402scan Ready Ready Preview, Comment Mar 4, 2026 7:58pm

Comment thread apps/scan/src/app/api/data/registry/register-origin/route.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant