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

Changing log_level causes premature exit #30

Closed
vsomayaji opened this issue Mar 24, 2022 · 5 comments · Fixed by #31
Closed

Changing log_level causes premature exit #30

vsomayaji opened this issue Mar 24, 2022 · 5 comments · Fixed by #31
Labels
bug Something isn't working

Comments

@vsomayaji
Copy link

Environment

Sentry SaaS with sentry_dart_plugin 1.0.0-beta.1.

Steps to Reproduce

  1. Set log_level to debug in pubspec.yaml.
sentry:
  auth_token: XXX
  log_level: debug # Uploading source maps will fail if this is lower than warn.
  org: my-org
  project: my-project
  upload_native_symbols: false
  upload_source_maps: true
  1. Run flutter packages pub run sentry_dart_plugin.

Expected Result

Source maps are uploaded.

Actual Result

After creating the release, the CLI exits prematurely because debug statements like this are written to STDERR:

stdout: Created release my_project@1.0.0+1.


stderr:   DEBUG   2022-03-23 22:59:35.150167 -07:00 sentry-cli version: 1.69.1, platform: "darwin", architecture: "x86_64"
  INFO    2022-03-23 22:59:35.150718 -07:00 sentry-cli was invoked with the following command line: "/Users/vsomayaji/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/sentry_dart_plugin-1.0.0-beta.1/lib/assets/sentry-cli-Darwin-x86_64" "--auth-token" "XXX" "--log-level" "trace" "releases" "--org" "my-org" "--project" "my-project" "new" "my_project@1.0.0+1"
  DEBUG   2022-03-23 22:59:35.150953 -07:00 request POST https://sentry.io/api/0/projects/my-org/my-project/releases/
  DEBUG   2022-03-23 22:59:35.150972 -07:00 using token authentication

This appears to be because this code exits whenever STDERR is not empty:

if (stderr != null && stderr.isNotEmpty) {
Log.error('stdout: $stdout');
Log.errorAndExit('stderr: $stderr', exitCode: result.exitCode);

@marandaneto marandaneto added the bug Something isn't working label Mar 24, 2022
@marandaneto
Copy link
Contributor

Thanks for reporting @vsomayaji

@marandaneto
Copy link
Contributor

Maybe we should change to:

    final isError = result.exitCode != 0;

    if (isError) {
      Log.errorAndExit('stderr: $stderr, stdout: $stdout',
          exitCode: result.exitCode);
    } else {
      Log.success('stderr: $stderr, stdout: $stdout');
    }

I'm not entirely sure if sentry-cli logs its debug output to stderr purposely or that's how Dart does its ProcessResult.
@kamilogorek do you know about it?

@marandaneto
Copy link
Contributor

@kamilogorek Do you know if exitCode is always 0 when successful and non-zero when is errored? can we rely on this to log the output correctly?

@kamilogorek
Copy link
Contributor

I'm not entirely sure if sentry-cli logs its debug output to stderr purposely or that's how Dart does its ProcessResult.
@kamilogorek do you know about it?

Yes, purposefully, but its a subject to change in v2 - getsentry/sentry-cli#1130

@kamilogorek Do you know if exitCode is always 0 when successful and non-zero when is errored? can we rely on this to log the output correctly?

Yes, exit codes are valid way to determine if something succeeded

@marandaneto
Copy link
Contributor

Thanks, so I guess the suggested change makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants