Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/commands/monitors/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ fn execute_checkin(
};

let envelopes_api = EnvelopesApi::try_new()?;
envelopes_api.send_envelope(open_checkin)?;

if let Err(e) = envelopes_api.send_envelope(open_checkin) {
log::error!("Failed to send in-progress check-in envelope: {e}");
log::info!("Continuing to run program...");
}

let (success, code, elapsed) = run_program(args, monitor_slug);

Expand All @@ -161,7 +165,11 @@ fn execute_checkin(
monitor_config: None,
};

envelopes_api.send_envelope(close_checkin)?;
if let Err(e) = envelopes_api.send_envelope(close_checkin) {
log::error!("Failed to send final check-in envelope: {e}");
log::info!("Continuing to exit with program's exit code...");
}

Ok((success, code))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```
$ sentry-cli monitors run foo-monitor -- cmd.exe /C echo 123
? success
[..]ERROR[..]Failed to send in-progress check-in envelope[..]
123
[..]ERROR[..]Failed to send final check-in envelope[..]

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```
$ sentry-cli monitors run foo-monitor -- echo 123
? success
[..]ERROR[..]Failed to send in-progress check-in envelope[..]
123
[..]ERROR[..]Failed to send final check-in envelope[..]

```
12 changes: 12 additions & 0 deletions tests/integration/monitors/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ fn command_monitors_run() {
}
}

#[test]
fn command_monitors_run_server_error() {
let _server =
integration::mock_endpoint(EndpointOptions::new("POST", "/api/1337/envelope/", 500));

#[cfg(not(windows))]
integration::register_test("monitors/monitors-run-server-error.trycmd");

#[cfg(windows)]
integration::register_test("monitors/monitors-run-server-error-win.trycmd");
}

#[test]
fn command_monitors_run_token_auth() {
let _server = integration::mock_endpoint(
Expand Down
Loading