Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

refactor: Adapt to async version of spawn#648

Merged
pgrzesik merged 1 commit intomasterserverless/serverless-python-requirements:masterfrom
migrate-spawn-sync-to-async-versionserverless/serverless-python-requirements:migrate-spawn-sync-to-async-versionCopy head branch name to clipboard
Nov 24, 2021
Merged

refactor: Adapt to async version of spawn#648
pgrzesik merged 1 commit intomasterserverless/serverless-python-requirements:masterfrom
migrate-spawn-sync-to-async-versionserverless/serverless-python-requirements:migrate-spawn-sync-to-async-versionCopy head branch name to clipboard

Conversation

@pgrzesik
Copy link
Contributor

Related to: #646 - sync use of spawn prevented interactive output to be updated

@pgrzesik pgrzesik self-assigned this Nov 24, 2021
@pgrzesik pgrzesik requested a review from medikoo November 24, 2021 11:37
try {
const pipTestRes = await spawn(pythonBin, ['-m', 'pip', 'help', 'install']);
return (
pipTestRes.stdoutBuffer &&
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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
Copy link
Contributor

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')

lib/docker.js Show resolved Hide resolved
@pgrzesik pgrzesik requested a review from medikoo November 24, 2021 12:01
Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 👍

@pgrzesik pgrzesik merged commit 50c2850 into master Nov 24, 2021
@pgrzesik pgrzesik deleted the migrate-spawn-sync-to-async-version branch November 24, 2021 12:08
@obataku
Copy link

obataku commented Dec 2, 2021

@pgrzesik which version of nodejs supports Buffer.trim? not seeing it in 17.x

@pgrzesik
Copy link
Contributor Author

pgrzesik commented Dec 2, 2021

Hello @obataku - I believe it's not supported at all on Buffer, are you observing some issues or such usage?

@obataku
Copy link

obataku commented Dec 2, 2021

@pgrzesik indeed, using dockerizePip with serverless-python-requirements@5.2.1 gives the following error:

  TypeError: ps.stdoutBuffer.trim is not a function
      at getDockerUid (.../node_modules/serverless-python-requirements/lib/docker.js:200:26)
      at async installRequirements (.../node_modules/serverless-python-requirements/lib/pip.js:341:30)
      at async installRequirementsIfNeeded (.../node_modules/serverless-python-requirements/lib/pip.js:682:3)
      at async ServerlessPythonRequirements.installAllRequirements (.../node_modules/serverless-python-requirements/lib/pip.js:760:29)

... 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();

@pgrzesik
Copy link
Contributor Author

pgrzesik commented Dec 2, 2021

Thanks for reporting, I see the issue now where the stdout was string (surprisingly it could also be a Buffer but for some reason it worked). I will prepare a fix for it and issue a new release 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.