Public
Likesqlite-fetch-failed-repro
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v10View latest version
When making SQLite calls via https://esm.town/v/std/sqlite after a long-running operation (like an AI call that takes 2-3 minutes), the SQLite request fails with:
Error: {"statusCode":500,"error":"Internal Server Error","message":"fetch failed"}
The bug occurs because something times out or disconnects during the long AI processing, and when we then try to call SQLite, the connection/context is stale or dead.
- Open the val's HTTP endpoint (click the endpoint URL)
- Configure the test:
- Set delay to 30-180 seconds (simulates AI call duration)
- Set iterations to 3+ (to catch intermittent failures)
- Click "Run Repro Test"
- Wait for the delay + SQLite operation
- Check results - look for red "FAIL" boxes with "fetch failed"
In dcm31/github-leads-wizard:
- User submits company to
/api/start createSession()does first SQLite INSERT ✅ (works - val is warm)generatePrompt()calls AI - takes 2-3 minutescreateSession()orupdateSession()does another SQLite call ❌ FAILS
The key insight: SQLite works before the long operation, fails after.
Error: {"statusCode":500,"error":"Internal Server Error","message":"fetch failed"}
at createResError (https://esm.town/v/std/sqlite?v=6:81:10)
at Object.execute (https://esm.town/v/std/sqlite?v=6:47:11)
at eventLoopTick (ext:core/01_core.js:179:7)
at async createSession (db.ts:40:3)
- Platform: Val Town
- SQLite Library:
https://esm.town/v/std/sqlite - Delay Library:
https://esm.town/v/std/delay - Original val:
dcm31/github-leads-wizard
main.ts- HTTP endpoint with test UIREADME.md- This filerepro-guide.md- Guide from repro.fyi on making minimal repros