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

Exit code ignored with SentryCli.execute([...], true) (live mode) #2062

Open
2 of 8 tasks
dotboris opened this issue May 7, 2024 · 5 comments
Open
2 of 8 tasks

Exit code ignored with SentryCli.execute([...], true) (live mode) #2062

dotboris opened this issue May 7, 2024 · 5 comments

Comments

@dotboris
Copy link

dotboris commented May 7, 2024

CLI Version

2.31.2

Operating System and Architecture

  • macOS (arm64)
  • macOS (x86_64)
  • Linux (i686)
  • Linux (x86_64)
  • Linux (armv7)
  • Linux (aarch64)
  • Windows (i686)
  • Windows (x86_64)

Operating System Version

Ubuntu 20.4 & MacOS 14.4.1

Link to reproduction repository

No response

CLI Command

No response

Exact Reproduction Steps

Run the following in a node REPL: node -i

> const SentryCli = require('@sentry/cli')
undefined
> await new SentryCli().execute(['does not exist'], true)
error: unrecognized subcommand 'does not exist'

Usage: sentry-cli [OPTIONS] <COMMAND>

For more information, try '--help'.
undefined

Note that under the hood, sentry-cli's exit code is 2 in this context.

Expected Results

I expect the execute([...], true) function to throw an Error that I can catch and react to. It does throw an error when the second argument is false but not when it's set to true.

Actual Results

No errors are thrown, the command ends as if everything was OK

Logs

There are no logs in this context

@szokeasaurusrex
Copy link
Member

Hi @dotboris, the problem appears to be that you are running the command with live = true (the second parameter passed to SentryCLI().execute. If you replace the call with the following, you will observe that the error is raised:

> await new SentryCLI().execute(['does not exist'])
Uncaught:
Error: Command failed: /Users/dszoke/node_modules/@sentry/cli-darwin/bin/sentry-cli does not exist
error: unrecognized subcommand 'does not exist'

Usage: sentry-cli [OPTIONS] <COMMAND>

For more information, try '--help'.

    at __node_internal_genericNodeError (node:internal/errors:866:15)
    at ChildProcess.exithandler (node:child_process:422:12)
    at ChildProcess.emit (node:events:514:28)
    at ChildProcess.emit (node:domain:551:15)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5)
    at Process.callbackTrampoline (node:internal/async_hooks:130:17) {
  code: 2,
  killed: false,
  signal: null,
  cmd: '/Users/dszoke/node_modules/@sentry/cli-darwin/bin/sentry-cli does not exist'
}

We should likely clarify the execute function's documentation comment to clarify that running with live=true suppresses any errors.

@dotboris
Copy link
Author

dotboris commented May 8, 2024

Thank you for pointing that out. In my case, I find the live option useful in my usecase. I believe that we should still get an error in this case as well. I'll update the issue to clarify.

@dotboris dotboris changed the title Exit code ignored with SentryCli.execute(...) Exit code ignored with SentryCli.execute([...], true) (live mode) May 8, 2024
@szokeasaurusrex
Copy link
Member

Hi @dotboris, can you please clarify why you need the live option? What does this option provide that you cannot achieve otherwise?

@dotboris
Copy link
Author

The live option streams the output of the sentry command directly to my process's stdout. This is the behaviour that I'm after. I'm writing a CLI that injects debug ids into my artifacts and then uploads them to sentry. The live option lets users see the output from the sentry cli as it happens.

@szokeasaurusrex
Copy link
Member

Okay, appreciate the clarification! I will see whether we can fix this behavior and respond once I have more information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants