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

fix: occasional ETXTBSY on CLI runs #4568

Merged
merged 2 commits into from
Apr 24, 2023
Merged

fix: occasional ETXTBSY on CLI runs #4568

merged 2 commits into from
Apr 24, 2023

Conversation

michelkaporin
Copy link
Contributor

@michelkaporin michelkaporin commented Apr 24, 2023

What does this PR do?

Customers see ETXTBSY error when running CLI on Linux systems.

This PR ensures that we resolve download function only upon close event, when both stream has finished and file descriptor is closed.

Executable doesn't exist, trying to download.
Downloading from 'https://static.snyk.io/cli/v1.1140.0/snyk-linux' to '/usr/local/lib/node_modules/snyk/wrapper_dist/snyk-linux'
...
Downloaded successfull!
{
  error: Error: spawnSync /usr/local/lib/node_modules/snyk/wrapper_dist/snyk-linux ETXTBSY
      at Object.spawnSync (internal/child_process.js:1107:20)
      at Object.spawnSync (child_process.js:776:24)
      at Object.runWrapper (/usr/local/lib/node_modules/snyk/wrapper_dist/common.js:142:33)
      at run (/usr/local/lib/node_modules/snyk/wrapper_dist/index.js:17:29)
      at /usr/local/lib/node_modules/snyk/wrapper_dist/index.js:34:26
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5) {
    errno: -26,
    code: 'ETXTBSY',
    syscall: 'spawnSync /usr/local/lib/node_modules/snyk/wrapper_dist/snyk-linux',
    path: '/usr/local/lib/node_modules/snyk/wrapper_dist/snyk-linux',
    spawnargs: [ 'test', '--severity-threshold=low' ]

Failed to spawn child process. (/usr/local/lib/node_modules/snyk/wrapper_dist/snyk-linux)
�[31m✖ Running snyk test failed.�[0m

Where should the reviewer start?

How should this be manually tested?

Any background context you want to provide?

I didn't manage to write tests in a reasonable time, as the current download implementation couples the download using https and the piping logic very tightly, making it very hard to test this scenario.

What are the relevant tickets?

https://snyk.zendesk.com/agent/tickets/45267

Screenshots

Additional questions

@michelkaporin michelkaporin requested review from a team as code owners April 24, 2023 07:52
@github-actions
Copy link
Contributor

github-actions bot commented Apr 24, 2023

Warnings
⚠️

Since the CLI is unifying on a standard and improved tooling, we're starting to migrate old-style imports and exports to ES6 ones.
A file you've modified is using either module.exports or require(). If you can, please update them to ES6 import syntax and export syntax.
Files found:

  • ts-binary-wrapper/src/common.ts
⚠️

"fix: ensure that downloadExecutable doesn't resolve until file descriptor is closed" is too long. Keep the first line of your commit message under 72 characters.

Generated by 🚫 dangerJS against d96f196

@michelkaporin michelkaporin merged commit cde8ca6 into master Apr 24, 2023
@michelkaporin michelkaporin deleted the fix/etxtbsy branch April 24, 2023 12:52
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

Successfully merging this pull request may close these issues.

2 participants