You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .cursor/rules/offline.mdc
+8-1Lines changed: 8 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -41,15 +41,20 @@ Envelope files are removed from the cache directory in the following scenarios:
41
41
### 1. Successful Send to Sentry Server
42
42
When `AsyncHttpTransport` successfully sends an envelope to the Sentry server, it calls `envelopeCache.discard(envelope)` to remove the cached file. This happens in `AsyncHttpTransport.EnvelopeSender.flush()` when `result.isSuccess()` is true.
43
43
44
-
### 2. Rate Limited Previously Cached Envelopes
44
+
### 2. Rate Limited Previously Cached Envelopes
45
45
If an envelope is dropped due to rate limiting **and** has previously been cached (indicated by the `Cached` hint), it gets discarded immediately via `envelopeCache.discard(envelope)` in `AsyncHttpTransport.send()`.
46
+
In this case the discarded envelope is recorded as lost in client reports.
46
47
47
48
### 3. Offline Cache Processing (EnvelopeSender)
48
49
When the SDK processes cached envelope files from disk (via `EnvelopeSender`), files are deleted after processing **unless** they are marked for retry. In `EnvelopeSender.processFile()`, the file is deleted with `safeDelete(file)` if `!retryable.isRetry()`.
49
50
50
51
### 4. Session File Management
51
52
Session-related files (session.json, previous_session.json) are removed during session lifecycle events like session start/end and abnormal exits.
52
53
54
+
### 5. Cache rotation
55
+
If the number of files in the cache directory has reached the configured limit (SentryOptions.maxCacheItems), the oldest file will be deleted to make room.
56
+
This happens in `CacheStrategy.rotateCacheIfNeeded`. The deleted envelope will be recorded as lost in client reports.
57
+
53
58
## Retry Mechanism
54
59
55
60
**Important**: The SDK does NOT implement a traditional "max retry count" mechanism. Instead:
@@ -66,6 +71,8 @@ Session-related files (session.json, previous_session.json) are removed during s
66
71
67
72
3. **Rate Limiting**: When envelope items are dropped due to active rate limits - recorded as `DiscardReason.RATELIMIT_BACKOFF`
68
73
74
+
4. **Cache Overflow**: When the cache directory has reached maxCacheItems, old files are deleted - recorded as `DiscardReason.CACHE_OVERFLOW`
75
+
69
76
### Cache Processing Triggers
70
77
Cached envelopes are processed when:
71
78
- Network connectivity is restored (via connection status observer)
0 commit comments