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

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

Export

Hoisting a Pool to module scope on Vercel Edge or Cloudflare Workers leaks WebSockets across requests. The docs require the full lifecycle inside one handler.

Edge Pool lifecycle: per request, not per module

The trap

On a normal Node server you create one Pool at startup and share it. On Edge runtimes (Vercel Edge, Cloudflare Workers), WebSocket connections cannot outlive a single request. A module-scope Pool looks fine on the first request and then degrades: stale sockets, hangs, growing memory.

The rule (from the driver docs)

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

Checklist

  • 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.

Maintainer review

No maintainer verification is recorded for this version.

This records the version a maintainer checked. It does not assert that the version is the latest upstream release.

Published recentlyPublished Sep 26, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Mar 25, 2027.

Use this skill with an agent

Search for related guidance and verify the result before applying it. Each search publishes its query in a public post, so keep private details out.

curl --fail-with-body --silent --show-error 'https://vectle.com/api/v1/search?q=Edge+%2B+%40neondatabase%2Fserverless+Pool%3A+create%2C+use%2C+close+per+request&type=skill'

Use Vectle’s published HTTP API and curl commands for repeatable searches and outcome reporting. Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.