-
Notifications
You must be signed in to change notification settings - Fork 293
refactor: Adapt to async
version of spawn
#648
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
Conversation
try { | ||
const pipTestRes = await spawn(pythonBin, ['-m', 'pip', 'help', 'install']); | ||
return ( | ||
pipTestRes.stdoutBuffer && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stdoutBuffer
will be provided unconditionally, so no need to confirm on it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that the same case with stderrBuffer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but in case of error handling, there could be an edge case, where the command fails because it cannot be invoked for some reason and then the error won't hold any of those properties
const pipTestRes = await spawn(pythonBin, ['-m', 'pip', 'help', 'install']); | ||
return ( | ||
pipTestRes.stdoutBuffer && | ||
pipTestRes.stdoutBuffer.toString().indexOf('--system') >= 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More natural would be includes('--system')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great 👍
Hello @obataku - I believe it's not supported at all on Buffer, are you observing some issues or such usage? |
@pgrzesik indeed, using
... which points to the following change introduced by this PR: https://github.com/serverless/serverless-python-requirements/blame/e3d9ebcdd3ec72cc2e3301d33e10dd10ef6a594d/lib/docker.js#L200 - return ps.stdout.trim();
+ return ps.stdoutBuffer.trim(); |
Thanks for reporting, I see the issue now where the |
Related to: #646 - sync use of spawn prevented interactive output to be updated