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
6 changes: 5 additions & 1 deletion src/backends/sentry_backend_crashpad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,9 @@ crashpad_backend_startup(

std::vector<std::string> arguments { "--no-rate-limit" };

char report_id[37];
sentry_uuid_as_string(&data->crash_event_id, report_id);

// Initialize database first, flushing the consent later on as part of
// `sentry_init` will persist the upload flag.
data->db = crashpad::CrashReportDatabase::Initialize(database).release();
Expand All @@ -564,7 +567,8 @@ crashpad_backend_startup(
minidump_url ? minidump_url : "", proxy_url, annotations, arguments,
/* restartable */ true,
/* asynchronous_start */ false, attachments, screenshot,
options->crashpad_wait_for_upload, crash_reporter, crash_envelope);
options->crashpad_wait_for_upload, crash_reporter, crash_envelope,
report_id);
sentry_free(minidump_url);

#ifdef SENTRY_PLATFORM_WINDOWS
Expand Down
12 changes: 12 additions & 0 deletions tests/assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ def assert_crashpad_upload(req, expect_attachment=False, expect_view_hierarchy=F
and b"\n\nMDMP" in part.as_bytes()
for part in msg.walk()
)
return attachments


def assert_gzip_file_header(output):
Expand All @@ -495,3 +496,14 @@ def assert_failed_proxy_auth_request(stdout):
and "407 Proxy Authentication Required" in stdout
and "200 OK" not in stdout
)


def wait_for_file(path, timeout=10.0, poll_interval=0.1):
import time

deadline = time.time() + timeout
while time.time() < deadline:
if path.exists():
return True
time.sleep(poll_interval)
return False
9 changes: 8 additions & 1 deletion tests/test_integration_crashpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
assert_gzip_file_header,
assert_logs,
assert_user_feedback,
wait_for_file,
)

pytestmark = pytest.mark.skipif(
Expand Down Expand Up @@ -410,11 +411,17 @@ def test_crashpad_dumping_crash(cmake, httpserver, run_args, build_args):

envelope = Envelope.deserialize(session)
assert_session(envelope, {"status": "crashed", "errors": 1})
assert_crashpad_upload(
attachments = assert_crashpad_upload(
multipart,
expect_attachment="clear-attachments" not in run_args,
expect_view_hierarchy="clear-attachments" not in run_args,
)
event_id = attachments.event["event_id"]
if sys.platform == "win32":
minidump = tmp_path / ".sentry-native" / "reports" / f"{event_id}.dmp"
else:
minidump = tmp_path / ".sentry-native" / "completed" / f"{event_id}.dmp"
assert wait_for_file(minidump)


@pytest.mark.parametrize(
Expand Down
Loading