Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COPY TO with query_timeout #156

Open
boromisp opened this issue May 17, 2024 · 0 comments
Open

COPY TO with query_timeout #156

boromisp opened this issue May 17, 2024 · 0 comments

Comments

@boromisp
Copy link

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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant