• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
dcm31

dcm31

sqlite-fetch-failed-repro

Minimal repro for SQLite "fetch failed" 500 error
Public
Like
sqlite-fetch-failed-repro
Home
Code
3
README.md
H
main.ts
repro-guide.md
Environment variables
Branches
1
Pull requests
Remixes
History
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.
Sign up now
Code
/
README.md
Code
/
README.md
Search
1/27/2026
Viewing readonly version of main branch: v11
View latest version
README.md

SQLite "fetch failed" 500 Error - Minimal Reproduction

The Bug

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"}

Hypothesis

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.

How to Reproduce

  1. Open the val's HTTP endpoint (click the endpoint URL)
  2. Configure the test:
    • Set delay to 30-180 seconds (simulates AI call duration)
    • Set iterations to 3+ (to catch intermittent failures)
  3. Click "Run Repro Test"
  4. Wait for the delay + SQLite operation
  5. Check results - look for red "FAIL" boxes with "fetch failed"

Original Context

In dcm31/github-leads-wizard:

  1. User submits company to /api/start
  2. createSession() does first SQLite INSERT ✅ (works - val is warm)
  3. generatePrompt() calls AI - takes 2-3 minutes
  4. createSession() or updateSession() does another SQLite call ❌ FAILS

The key insight: SQLite works before the long operation, fails after.

Stack Trace

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)

Environment

  • 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

Files

  • main.ts - HTTP endpoint with test UI
  • README.md - This file
  • repro-guide.md - Guide from repro.fyi on making minimal repros
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.