Skip to content

fix(tracing): Don't start AsyncExpiringMap cleanup interval at import time - #6811

Open
antonis wants to merge 3 commits into
mainfrom
fix/async-expiring-map-import-timer
Open

antonis wants to merge 3 commits into
mainfrom
fix/async-expiring-map-import-timer

Conversation

@antonis

@antonis antonis commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

  • Removed the startCleanup() call from the constructor. set() already starts the interval lazily on the first entry, and an empty map has nothing to sweep.
  • stopCleanup() now resets _cleanupInterval = undefined, so set() can re-arm cleanup after the map empties. clear() routes through stopCleanup() for a single teardown path.
  • startCleanup() calls .unref?.() on the interval where supported (Node), so an active map never keeps a Node process alive on its own. It is a no-op on React Native, where setInterval returns a number.

💡 Motivation and Context

Fixes #6805.

💚 How did you test it?

  • Added two regression tests, both verified red on the pre-fix source, green after:
    • does not start a cleanup interval on construction (asserts jest.getTimerCount() is unchanged by construction).
    • restarts the cleanup interval after the map empties and a new entry is added (asserts via the internal map that the interval — not a lazy read — evicts the entry).
  • Manual testing

📝 Checklist

  • I added tests to verify 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.
  • All tests passing.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • No breaking changes.

🔮 Next steps

… time

`timeToDisplayFallback.ts` creates an `AsyncExpiringMap` at module scope, whose
constructor started a `setInterval` without `.unref()`. Importing the SDK was
therefore enough to keep a Node/Jest process from exiting cleanly.

The interval is now started lazily on the first `set()` (as the existing `set()`
guard already intended), `stopCleanup()` resets the handle so cleanup can
actually restart after the map empties, and the interval is `unref`'d where
supported so it never keeps a Node process alive.

Fixes #6805

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

⚪ None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • fix(tracing): Don't start AsyncExpiringMap cleanup interval at import time by antonis in #6811
  • fix(ios): Keep -force_load when another pod sets OTHER_LDFLAGS[sdk=…] by antonis in #6801
  • fix(android): Remove unused RNSentryReplayFragmentLifecycleTracer by antonis in #6803
  • feat(ios): Support SPM autolinking by alwx in #6784
  • chore(deps): bump brace-expansion from 1.1.18 to 1.1.21 by dependabot in #6809
  • chore(deps): bump moment from 2.30.1 to 2.31.0 by dependabot in #6808
  • chore(deps): bump undici from 6.28.0 to 6.29.0 by dependabot in #6806
  • chore(deps): update Maestro to v2.11.0 by github-actions in #6804
  • fix(ios): Preserve quoted Expo bundle script invocations by eliotgevers in #6796
  • chore(deps): bump ip-address from 10.4.0 to 10.7.2 by dependabot in #6799
  • chore(deps): bump fast-uri from 3.1.6 to 3.1.8 by dependabot in #6797
  • chore(deps): update Sentry Android Gradle Plugin to v6.23.0 by github-actions in #6798
  • build(deps): Bump fastlane to 2.240.1 to resolve rubyzip advisory by antonis in #6788
  • chore(deps): bump getsentry/craft from 2.31.0 to 2.31.2 by dependabot in #6793
  • chore(deps): bump the codeql-action group with 3 updates by dependabot in #6789
  • chore(deps): bump ruby/setup-ruby from 1.324.0 to 1.327.0 by dependabot in #6790
  • chore(deps): bump getsentry/github-workflows/updater from 3.4.0 to 3.4.1 by dependabot in #6792
  • chore(deps): bump getsentry/github-workflows/danger from 4013fc6e1aeb1be1f9d3b4d232624f0ec1afa613 to 36c729264d2edc29ebae61950c50e1e9f043ad7e by dependabot in #6791
  • chore(deps): update Cocoa SDK to v9.29.2 by github-actions in #6787
  • feat(replay): Populate trace_ids in mobile replay events by antonis in #6786
  • chore(deps): update Cocoa SDK to v9.29.1 by github-actions in #6785
  • chore(deps): update Android SDK to v8.58.0 by github-actions in #6778
  • fix(build): Prevent update-android.sh from failing on SIGPIPE by antonis in #6777
  • chore(deps): update Wizard to v8.0.0 by github-actions in #6775

🤖 This preview updates automatically when you update the PR.

@antonis antonis added ready-to-merge Triggers the full CI test suite and removed ready-to-merge Triggers the full CI test suite labels Sep 30, 2026
Comment thread CHANGELOG.md Outdated
@sentry

sentry Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Sentry RN io.sentry.reactnative.sample 8.28.0 (108) Release

⚙️ sentry-react-native Build Distribution Settings

@antonis antonis added the ready-to-merge Triggers the full CI test suite label Sep 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 3852.24 ms 1228.79 ms -2623.45 ms
Size 5.15 MiB 6.93 MiB 1.78 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
64630e5+dirty 3842.70 ms 1218.11 ms -2624.60 ms
b0d3373+dirty 3831.75 ms 1227.29 ms -2604.46 ms
b04af96+dirty 3818.92 ms 1219.76 ms -2599.16 ms
3d31fcf+dirty 3838.09 ms 1223.46 ms -2614.63 ms
a0a3177+dirty 3844.73 ms 1225.23 ms -2619.51 ms
af33f3b+dirty 3849.98 ms 1236.45 ms -2613.53 ms
09a902f+dirty 3835.67 ms 1217.11 ms -2618.57 ms
5a316ea+dirty 3820.11 ms 1211.28 ms -2608.83 ms
acd838e+dirty 3849.78 ms 1230.00 ms -2619.78 ms
c2e182c+dirty 3848.40 ms 1211.79 ms -2636.61 ms

App size

Revision Plain With Sentry Diff
64630e5+dirty 4.98 MiB 6.46 MiB 1.49 MiB
b0d3373+dirty 5.15 MiB 6.68 MiB 1.53 MiB
b04af96+dirty 4.98 MiB 6.54 MiB 1.56 MiB
3d31fcf+dirty 4.98 MiB 6.56 MiB 1.58 MiB
a0a3177+dirty 4.98 MiB 6.55 MiB 1.58 MiB
af33f3b+dirty 4.98 MiB 6.51 MiB 1.54 MiB
09a902f+dirty 4.98 MiB 6.46 MiB 1.49 MiB
5a316ea+dirty 4.98 MiB 6.51 MiB 1.53 MiB
acd838e+dirty 5.15 MiB 6.70 MiB 1.55 MiB
c2e182c+dirty 4.98 MiB 6.50 MiB 1.52 MiB

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit e78be26. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 3879.46 ms 1253.91 ms -2625.54 ms
Size 5.15 MiB 6.93 MiB 1.78 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
64630e5+dirty 3845.49 ms 1215.19 ms -2630.30 ms
b0d3373+dirty 3842.49 ms 1218.49 ms -2624.00 ms
b04af96+dirty 3830.54 ms 1206.11 ms -2624.44 ms
f9c1ed4+dirty 3842.09 ms 1220.70 ms -2621.40 ms
09a902f+dirty 3847.65 ms 1221.31 ms -2626.34 ms
44abcc2+dirty 3841.42 ms 1214.77 ms -2626.65 ms
acd838e+dirty 3835.94 ms 1215.87 ms -2620.07 ms
bfba737+dirty 3834.18 ms 1222.80 ms -2611.38 ms
ce7b368+dirty 3851.41 ms 1222.37 ms -2629.04 ms
4e0ba9c+dirty 3856.39 ms 1234.44 ms -2621.95 ms

App size

Revision Plain With Sentry Diff
64630e5+dirty 4.98 MiB 6.46 MiB 1.49 MiB
b0d3373+dirty 5.15 MiB 6.68 MiB 1.53 MiB
b04af96+dirty 4.98 MiB 6.54 MiB 1.56 MiB
f9c1ed4+dirty 4.98 MiB 6.50 MiB 1.53 MiB
09a902f+dirty 4.98 MiB 6.46 MiB 1.49 MiB
44abcc2+dirty 4.98 MiB 6.55 MiB 1.57 MiB
acd838e+dirty 5.15 MiB 6.70 MiB 1.55 MiB
bfba737+dirty 4.98 MiB 6.51 MiB 1.53 MiB
ce7b368+dirty 4.98 MiB 6.51 MiB 1.53 MiB
4e0ba9c+dirty 5.15 MiB 6.67 MiB 1.51 MiB

@github-actions

Copy link
Copy Markdown
Contributor

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 421.43 ms 465.55 ms 44.12 ms
Size 50.56 MiB 56.51 MiB 5.95 MiB

@github-actions

Copy link
Copy Markdown
Contributor

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 415.46 ms 439.98 ms 24.52 ms
Size 50.56 MiB 56.51 MiB 5.95 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
3817909+dirty 406.67 ms 416.58 ms 9.91 ms
e763471+dirty 426.57 ms 458.21 ms 31.64 ms
0bd8916+dirty 412.77 ms 451.31 ms 38.54 ms
bfba737+dirty 419.52 ms 462.68 ms 43.16 ms
bc0d8cf+dirty 412.37 ms 466.26 ms 53.89 ms
bf168a4+dirty 418.21 ms 489.74 ms 71.53 ms
4acd4e9+dirty 414.45 ms 448.55 ms 34.10 ms
1122a96+dirty 422.22 ms 464.33 ms 42.10 ms
1a5721e+dirty 424.07 ms 482.32 ms 58.25 ms
267d3ed+dirty 413.06 ms 440.96 ms 27.90 ms

App size

Revision Plain With Sentry Diff
3817909+dirty 43.75 MiB 48.08 MiB 4.33 MiB
e763471+dirty 49.74 MiB 54.85 MiB 5.11 MiB
0bd8916+dirty 48.30 MiB 53.57 MiB 5.26 MiB
bfba737+dirty 49.74 MiB 55.09 MiB 5.34 MiB
bc0d8cf+dirty 48.30 MiB 53.48 MiB 5.18 MiB
bf168a4+dirty 49.74 MiB 55.09 MiB 5.35 MiB
4acd4e9+dirty 49.74 MiB 55.26 MiB 5.52 MiB
1122a96+dirty 48.30 MiB 53.54 MiB 5.24 MiB
1a5721e+dirty 49.74 MiB 55.09 MiB 5.34 MiB
267d3ed+dirty 48.30 MiB 53.58 MiB 5.28 MiB

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

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AsyncExpiringMap starts an interval at import time (keeps Jest alive) and never restarts cleanup once stopped

1 participant