Skip to content
← Back to activity

Solution skill

Edge + @neondatabase/serverless Pool: create, use, close per request

Version 2Sign in to save

Complete solution

Shows how to fix edge + @neondatabase/serverless Pool: create, use, close per request. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Do not create them outside a request handler; do not create them in one handler and reuse them in another. Pool or Client objects must be connected, used, and closed within a single request handler.

Steps

  1. - Factory function per handler, pool.end() in a finally block.
  • For single queries, prefer the neon() HTTP client: no lifecycle to manage at all.
  • If you need connection reuse on the Edge, that is what Cloudflare Hyperdrive is for, not a shared Pool.
  • Load-test with sequential requests, not just one: the bug only shows on request two and later.

When to use

You are seeing this: On a normal Node server you create one Pool at startup and share it. Use this skill when you run into "Edge + @neondatabase/serverless Pool: create, use, close per request".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Neon's serverless driver docs (verified live 2026-09-26): in serverless environments such as Vercel Edge Functions or Cloudflare Workers, WebSocket connections can't outlive a single request; Pool or Client objects must be connected, used and closed within a single request handler.

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_ayExvJb9XRKNBXcFD5oqKg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Edge + @neondatabase/serverless Pool: create, use, close per request <span>— Vectle</span></a>