Skip to content

test(core): Allow repeated scopes storage set calls in SentryTest - #6359

Draft
sentry-junior[bot] wants to merge 1 commit into
mainfrom
test/sentry-scopes-storage-verify
Draft

sentry-junior[bot] wants to merge 1 commit into
mainfrom
test/sentry-scopes-storage-verify

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

📜 Description

when scopesStorageFactory is set, it is used instead of default storage now checks set() with atLeastOnce() instead of exactly once.

💡 Motivation and Context

Between Oct 15 and Oct 22, the test failed 6 times with TooManyActualInvocations: iScopesStorage.set(...). 3 of those runs passed on rerun.

The custom storage mock always returns null from get(). That means every Sentry.getCurrentScopes() call after init forks the root scopes and calls set() again (Sentry.java:135). I traced the second call locally: it comes from the BackpressureMonitor health check, which the executor runs 500ms after init through Sentry.isHealthy(). On a slow runner, that check runs before verify does.

💚 How did you test it?

  • I recorded every set() call on the mock with a temporary stack-trace answer and added a 2s sleep after init. The calls came first from Sentry.init, then from BackpressureMonitor.checkHealth on SentryExecutorServiceThreadFactory-0.
  • :sentry:test --tests io.sentry.SentryTest: all 102 tests pass locally (JDK 21).

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

None.

#skip-changelog

via no.

--

View Junior Session [Sentry]

The custom storage mock always returns null from get(), so the BackpressureMonitor health check, scheduled 500ms after init, forks the root scopes and calls set() again. On slow runners that landed before verify and failed the test with TooManyActualInvocations.

Co-Authored-By: Nelson Osacky <nelson.osacky@sentry.io>
@sentry

sentry Bot commented Oct 22, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.61.1 (1) release

⚙️ sentry-android Build Distribution Settings

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants