Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[pg-query-stream] Allow 'destroy' option for QueryStream

オープン
#3,546 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
node.js, postgresql
領域
backend, databases

調査の方向性

QueryStream の実装から始め、その Node.js ストリームスーパークラスを調べ、construct オプションと destroy オプションを super() に渡せるようにする方法に焦点を当てます。QueryStream がそれらのオプションを受け取り、転送できるようになり、追加の PassThrough オブジェクトなしで接続をクリーンアップできれば完了です。

索引モデルが issue の本文から書いたものです。

説明

feature request

Since I'm using QueryStream for a one-off task, I'd like to wrap it with a function that manages the connection for me.

export function streamAllRows(
  config: ClientConfig,
  query: string,
): stream.Readable;

However, client code needs to wait not just for the QueryStream to close, but also for the managed connection and client to be fully closed and ended.

My solution was to use the destroy argument to stream.PassThrough:

export async function streamAllRows(
  config: ClientConfig,
  query: string,
): Promise<stream.Readable> {
  const client = new pg.Client(config);
  await client.connect();
  return client.query(new QueryStream(query))
    .pipe(new stream.PassThrough({
      objectMode: true,
      destroy: (e: Error | null, callback) => {
        void client.end().then(() => { callback(); }).catch(callback);
      },
    }));
}

This works well enough, but creates an extra object and seems unnecessarily circuitous. It would be more expressive to accept the construct and destroy arguments and forward them to super().

主要言語
JavaScript
スター
13.2k
フォーク
1.4k
平均マージ
6日 15時間
マージ済み PR(30日)
6

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

brianc/node-postgres のほかの issue

brianc/node-postgres の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。