Skip to content
Draft
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
**Features**:

- Add HTTP retry with exponential backoff. ([#1520](https://github.com/getsentry/sentry-native/pull/1520))
- Add offline caching support to the new experimental `native` backend. ([#1585](https://github.com/getsentry/sentry-native/pull/1585))

**Fixes**:

Expand Down
1 change: 1 addition & 0 deletions src/backends/native/sentry_crash_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ typedef struct {
int crash_reporting_mode; // sentry_crash_reporting_mode_t
bool debug_enabled; // Debug logging enabled in parent process
bool attach_screenshot; // Screenshot attachment enabled in parent process
bool cache_keep;

// Platform-specific crash context
#if defined(SENTRY_PLATFORM_LINUX) || defined(SENTRY_PLATFORM_ANDROID)
Expand Down
2 changes: 2 additions & 0 deletions src/backends/native/sentry_crash_daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -2966,6 +2966,8 @@ sentry__crash_daemon_main(pid_t app_pid, uint64_t app_tid, HANDLE event_handle,
// Use debug logging and screenshot settings from parent process
sentry_options_set_debug(options, ipc->shmem->debug_enabled);
options->attach_screenshot = ipc->shmem->attach_screenshot;
options->cache_keep = ipc->shmem->cache_keep;
options->http_retry = false;

// Set custom logger that writes to file
if (log_file) {
Expand Down
1 change: 1 addition & 0 deletions src/backends/sentry_backend_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ native_backend_startup(
// Pass debug logging setting to daemon
ctx->debug_enabled = options->debug;
ctx->attach_screenshot = options->attach_screenshot;
ctx->cache_keep = options->cache_keep;

// Set up event and breadcrumb paths
sentry_path_t *run_path = options->run->run_path;
Expand Down
3 changes: 2 additions & 1 deletion tests/assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,11 +559,12 @@ def assert_failed_proxy_auth_request(stdout):


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

deadline = time.time() + timeout
while time.time() < deadline:
if path.exists():
if glob.glob(str(path)):
return True
time.sleep(poll_interval)
return False
25 changes: 25 additions & 0 deletions tests/test_integration_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from .assertions import (
assert_meta,
assert_session,
wait_for_file,
)
from .conditions import has_native, is_kcov, is_asan

Expand Down Expand Up @@ -626,3 +627,27 @@ def test_crash_mode_native_with_minidump(cmake, httpserver):

# Should have debug_meta
assert "debug_meta" in event


@pytest.mark.parametrize("cache_keep", [True, False])
def test_native_cache_keep(cmake, cache_keep):
tmp_path = cmake(["sentry_example"], {"SENTRY_BACKEND": "native"})
db_dir = tmp_path / ".sentry-native"
cache_dir = db_dir / "cache"
unreachable_dsn = "http://uiaeosnrtdy@127.0.0.1:19999/123456"
env = dict(os.environ, SENTRY_DSN=unreachable_dsn)

# crash -> daemon sends via HTTP -> unreachable -> cache
run_crash(
tmp_path,
"sentry_example",
["log", "stdout", "crash"] + (["cache-keep"] if cache_keep else []),
env=env,
)

if cache_keep:
assert wait_for_file(cache_dir / "*.envelope")
assert len(list(cache_dir.glob("*.envelope"))) == 1
else:
time.sleep(2)
assert len(list(cache_dir.glob("*.envelope"))) == 0
Loading