heroku / cli

Heroku CLI
https://devcenter.heroku.com/articles/heroku-cli
ISC License
851 stars 223 forks source link

RangeError: Invalid string length on `heroku pg:psql` copy with lots of data #1421

Open JacobEvelyn opened 4 years ago

JacobEvelyn commented 4 years ago

What is the current behavior?

With a small table:

DEBUG=* heroku pg:psql -a my-heroku-app -c "COPY (SELECT * FROM small_table) TO STDOUT;" > ~/Downloads/table.dump
...
  pg Using "DATABASE_URL" to connect to your database… +745ms
--> Connecting to postgresql-whatever-12345
  pg Running query: COPY (SELECT * FROM small_table) TO STDOUT; +2ms

# Completes successfully and data is in ~/Downloads/table.dump

But when there's more data:

DEBUG=* heroku pg:psql -a my-heroku-app -c "COPY (SELECT * FROM very_large_table) TO STDOUT;" > ~/Downloads/table.dump
...
  pg Using "DATABASE_URL" to connect to your database… +701ms
--> Connecting to postgresql-whatever-12345
  pg Running query: COPY (SELECT * FROM very_large_table)  TO STDOUT; +2ms
/Users/jacobevelyn/.local/share/heroku/client/7.35.1/node_modules/@heroku-cli/plugin-pg-v5/lib/psql.js:24
      result += data.toString()
                     ^

RangeError: Invalid string length
    at Socket.<anonymous> (/Users/jacobevelyn/.local/share/heroku/client/7.35.1/node_modules/@heroku-cli/plugin-pg-v5/lib/psql.js:24:22)
    at Socket.emit (events.js:210:5)
    at addChunk (_stream_readable.js:308:12)
    at readableAddChunk (_stream_readable.js:289:11)
    at Socket.Readable.push (_stream_readable.js:223:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:182:23)

What is the expected behavior?

The second example above should complete successfully, like the first.

This is happening on Heroku CLI version heroku/7.35.1 darwin-x64 node-v12.13.0 on macOS 10.15.2. I'm not behind an HTTP proxy or firewall.

kferch-teamworks commented 2 years ago

+1