porsager / porsager/postgres

READABLE from COPY does not recieve close event

Open
#917 0 comments 1 reaction 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 am using a postgres client to run COPY on the server to stdout into a readable stream. I am using pipeline and noticing that sometimes pipeline hangs indefinetly due to the readabel stream never getting the 'close' event. I provided sample code below. I'm trying to read the output of copy to a local file.

await pipeline(
          await sourceSql`COPY (${sourceSql.unsafe(
      'select * from test where id = ' +
        id
    )}) to stdout WITH (FORMAT CSV, NULL "NULL", HEADER)`.readable();,
          createWriteStream(
            `${os.homedir()}/cms/${testName}`
          )
        );
      }

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

Use the reported PostgreSQL COPY-to-stdout call and its .readable() entry point with the pipeline and createWriteStream example; first reproduce whether the readable stream emits close. Done means the pipeline completes and the COPY output is written to the local file without hanging.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs, postgresql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.