porsager / porsager/postgres

A reserved/released ReservedSql prevents the main Sql from ending

Open
#925 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
8.7k
Forks
374
Avg merge
11d 16h
Merged PRs (30d)
1

Description

Awesome library! Thanks so far. I have a small issue though... this works fine:

const sql1 = postgres(process.env.DATABASE_URL);
await sql1.end();

But this hangs indefinitely:

const sql1 = postgres(process.env.DATABASE_URL);

  const sql2 = await sql1.reserve();
  sql2.release();

await sql1.end(); // never completes

Once I have reserved/released a ReservedSql connection, the only way I can end the whole thing cleanly is to add a timeout with await sql1.end({timeout: 0.1});.

By the way, I notice that the .release method doesn't seem asynchronous, even though the example in the readme has an await. That doesn't fix this issue though.

Is this expected? Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the minimal JavaScript example and inspect the connection lifecycle behind reserve(), release(), and end(). Done means a released reserved connection no longer prevents sql1.end() from completing without a timeout, with regression coverage for the reported sequence.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, postgres
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.