Skip to content

Commit d2c7e95

Browse files
committed
add latest learnings
1 parent dffab26 commit d2c7e95

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

.cursor/rules/offline.mdc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,20 @@ Envelope files are removed from the cache directory in the following scenarios:
4141
### 1. Successful Send to Sentry Server
4242
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.
4343

44-
### 2. Rate Limited Previously Cached Envelopes
44+
### 2. Rate Limited Previously Cached Envelopes
4545
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.
4647

4748
### 3. Offline Cache Processing (EnvelopeSender)
4849
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()`.
4950

5051
### 4. Session File Management
5152
Session-related files (session.json, previous_session.json) are removed during session lifecycle events like session start/end and abnormal exits.
5253

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+
5358
## Retry Mechanism
5459

5560
**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
6671

6772
3. **Rate Limiting**: When envelope items are dropped due to active rate limits - recorded as `DiscardReason.RATELIMIT_BACKOFF`
6873

74+
4. **Cache Overflow**: When the cache directory has reached maxCacheItems, old files are deleted - recorded as `DiscardReason.CACHE_OVERFLOW`
75+
6976
### Cache Processing Triggers
7077
Cached envelopes are processed when:
7178
- Network connectivity is restored (via connection status observer)

0 commit comments

Comments
 (0)