feat: add redundant worker deployments on Deno Deploy and Vercel#354
Open
AugustoL wants to merge 9 commits intoopenscan-explorer:devfrom
Open
feat: add redundant worker deployments on Deno Deploy and Vercel#354AugustoL wants to merge 9 commits intoopenscan-explorer:devfrom
AugustoL wants to merge 9 commits intoopenscan-explorer:devfrom
Conversation
Add entry-deno.ts that sources env vars from Deno.env and passes them to the shared Hono app via app.fetch(request, env). All existing route handlers and middleware work unchanged. Add deno.json with sloppy-imports for Node-style resolution and npm import maps for the hono dependency. Ref openscan-explorer#339
Add api/index.ts that sources env vars from process.env and passes them to the shared Hono app via app.fetch(request, env). All existing route handlers and middleware work unchanged. Add vercel.json with a catch-all rewrite to route all paths to the edge function handler. Ref openscan-explorer#339
Add fetchWithWorkerFailover() that tries each worker URL in order (Cloudflare → Deno Deploy → Vercel) and falls through on network errors, 429, 502, and 503 responses. Update all direct worker proxy consumers (contractLookup, useEtherscan, AIService) to use the failover function. Update isWorkerProxyUrl to check against all worker URLs. Closes openscan-explorer#339
|
🚀 Preview: https://pr-354--openscan.netlify.app |
The worker tsconfig only includes @cloudflare/workers-types, so process.env is unknown. Declare it locally instead of adding @types/node.
Document the worker proxy architecture, routes, environment variables, and step-by-step deployment instructions for Cloudflare Workers, Deno Deploy, and Vercel Edge Functions.
Deno Deploy entry point and config remain available for future use but are not included in the active failover chain until deployment is configured. Failover is now Cloudflare → Vercel.
MatiasOS
approved these changes
Apr 8, 2026
Member
MatiasOS
left a comment
There was a problem hiding this comment.
It would be great to add how the workers are used within the app
Merge dev into feat/worker-multi-platform-deploy and resolve the workerConfig.ts conflict. The primary worker URL now reads from import.meta.env.OPENSCAN_WORKER_URL (matching the REACT_APP_ → Vite env migration already on dev) while keeping the failover array and fetchWithWorkerFailover logic from this branch.
- Add 15s AbortController timeout per request so a hanging worker doesn't block the entire failover chain - On 429 (rate limited): wait Retry-After header (capped at 10s, default 3s) and retry once on the same worker before failing over - 502/503 still trigger immediate failover to the next worker - Extracted fetchWithTimeout helper for clean abort handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add support for deploying the OpenScan worker proxy on Vercel Edge Functions alongside the existing Cloudflare Workers deployment. A Deno Deploy entry point is also included for future use. The frontend automatically fails over between platforms.
Related Issue
Closes #339
Type of Change
Changes Made
Deno Deploy entry point (ready for future activation):
worker/src/entry-deno.ts: Sources env vars fromDeno.envand passes them to the shared Hono app viaapp.fetch(request, env)worker/deno.json: Config with sloppy-imports for Node-style resolution and npm import maps for honoVercel Edge Functions (active failover):
worker/api/index.ts: Sources env vars fromprocess.envand passes them to the shared Hono appworker/vercel.json: Catch-all rewrite to route all paths to the edge function handlerhttps://openscan-worker-proxy.vercel.appFrontend failover:
src/config/workerConfig.ts: ExportsWORKER_URLSarray (Cloudflare → Vercel) andfetchWithWorkerFailover()that tries each URL in order, falling through on network errors, 429, 502, and 503 responsescontractLookup.ts,useEtherscan.ts,AIService.tsto usefetchWithWorkerFailoverfor all direct worker proxy callsisWorkerProxyUrlto check against all worker URLsDocumentation:
worker/README.md: Architecture overview, routes table, env vars, and step-by-step deployment guides for Cloudflare, Deno Deploy, and VercelArchitecture: All platforms share the exact same Hono app (
worker/src/index.ts). Each entry point just bridges platform-specific env var access into Hono'sapp.fetch(request, env)— zero code duplication.Verified Endpoints (Vercel)
GET /health—{"status":"ok"}POST /evm/alchemy/eip155:1— Returns block number (eth_blockNumber)POST /etherscan/verify— Returns verified contract source code and ABIChecklist
npm run format:fixandnpm run lint:fixnpm run typecheckwith no errorsnpm run test:runAdditional Notes
WORKER_URLS.rpcStorage.tsstill use only the primary Cloudflare URL, which is fine since the RPC client already has multi-provider fallback (Alchemy, Infura, dRPC, Ankr). The critical single-provider paths (AI and Etherscan) are covered by the failover.