fix(pg-v5): return child process stdout #1701
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://heroku.support/945120
In PR #1691, some refactoring was done to make the way psql is executed more consistent. Unfortunately, this ended up in a regression for commands that were expecting the result of
PSQL.exec
to return a promise that resolved with the result of the psql child_process's stdout stream. PreviouslyPSQL.exec
's resolved value would be a string. While the output is displayed, some commands, likeps
were looking at the return result ofpsql.exec
. Because #1691 made this returnundefined
, rather than astring
, downstream commands likeps
or others now error.This changes the behavior in
packages/pg-v5/lib/psql.js
back to what it was doing before:psql.exec
with the value of the psql child_process'sstdout
streamIdeally, long term, we would return the child process (or a wrapper) and let callers decide to do with output themselves. Node has a lot of great utilities to make this easier. I tried going down this route but it ended up being a larger change than intended due to tests. In the interest of fixing this issue quickly, let's go with this approach until we can revisit the return value of
PSQL.exec
in the future.How to verify?
cd packages/pg-v5
heroku plugins:link
heroku pg:ps -a someappwithpostgres
heroku plugins:unlink
to uninstall this local branch **