Similarly to brianc/node-postgres#3219, COPY TO doesn't play nice with query_timeout. #126 fixed this issue for COPY FROM.
I've been using this patch for some time now, and it seems to work:
const { to: copyTo } = require('pg-copy-streams');
const fixedCopyTo = (query, options) => {
const streamQuery = copyTo(query, options);
streamQuery.callback = () => {};
const handleError = streamQuery.handleError.bind(streamQuery);
const handleReadyForQuery = streamQuery.handleReadyForQuery.bind(streamQuery);
streamQuery.handleError = e => {
streamQuery.callback();
handleError(e);
};
streamQuery.handleReadyForQuery = () => {
streamQuery.callback();
handleReadyForQuery();
};
return streamQuery;
};
module.exports = fixedCopyTo;
Similarly to brianc/node-postgres#3219,
COPY TOdoesn't play nice withquery_timeout. #126 fixed this issue forCOPY FROM.I've been using this patch for some time now, and it seems to work: