postgres icon indicating copy to clipboard operation
postgres copied to clipboard

READABLE from COPY does not recieve close event

Open Ivor808 opened this issue 1 year ago • 0 comments

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}`
          )
        );
      }

Ivor808 avatar Jul 23 '24 04:07 Ivor808