porsager / porsager/postgres

Symbol.asyncDispose support

Open
#1,094 0 comments 0 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

I propose support AsyncDisposable on postgres.Sql (https://github.com/tc39/proposal-explicit-resource-management) so that developers can opt-into ending the connection automatically at the end of the current scope.

before

import postgres from "postgres";

const sql = postgres();

const result = await sql`SELECT * FROM some_table`;

console.log(result);

await sql.end();

after

import postgres from "postgres";

await using sql = postgres();

const result = await sql`SELECT * FROM some_table`;

console.log(result);

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 at the postgres.Sql API and compare its current connection lifecycle with the TC39 Explicit Resource Management proposal. Verify that await using sql = postgres() supports Symbol.asyncDispose and closes the connection with the same effect as await sql.end(); the issue provides no file or test path, so locate the existing lifecycle tests first.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, postgresql
Domain
backend-api-design, databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.