Tests for potential memory leaks in the postgres npm package when used in Cloudflare Workers.
- Start PostgreSQL:
docker-compose up -d - Install deps:
npm install - Run worker:
npm run dev - Test endpoint:
curl http://localhost:8787/leak-test
The /leak-test endpoint creates a postgres connection, executes SELECT 1, and closes with sql.end(). Repeated requests help identify memory leaks.
Monitor memory usage with Cloudflare Workers dev tools: https://developers.cloudflare.com/workers/observability/dev-tools/memory-usage/
Chrome DevTools memory profiler showing increased object retention after repeated requests:
