postgres
postgres copied to clipboard
READABLE from COPY does not recieve close event
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}`
)
);
}