Skip to content

fix(core): do not unnecessarily defer offline transport send - #24027

Open
isaacs wants to merge 1 commit into
developfrom
isaacs/fix-24005
Open

fix(core): do not unnecessarily defer offline transport send#24027
isaacs wants to merge 1 commit into
developfrom
isaacs/fix-24005

Conversation

@isaacs

@isaacs isaacs commented Sep 3, 2026

Copy link
Copy Markdown
Member

makeOfflineTransport awaited the shouldSend result unconditionally. The option type allows a plain boolean, and awaiting one still costs a microtask tick, so a synchronous callback pushed the call to transport.send() into the next turn.

Only await when the callback returns a thenable. Hosts such as Douyin mini-games stop JS execution when the app goes to the background, so that one tick was enough to lose the event: the envelope had not reached the transport, and the offline store only gets written in the catch branch, which never runs when shouldSend returns true.

Behavior is unchanged for callbacks that return a promise.

fixes #24005
fixes JS-3560

`makeOfflineTransport` awaited the `shouldSend` result unconditionally.
The option type allows a plain boolean, and awaiting one still costs a
microtask tick, so a synchronous callback pushed the call to
`transport.send()` into the next turn.

Only await when the callback returns a thenable. Hosts such as Douyin
mini-games stop JS execution when the app goes to the background, so
that one tick was enough to lose the event: the envelope had not
reached the transport, and the offline store only gets written in the
`catch` branch, which never runs when `shouldSend` returns true.

Behavior is unchanged for callbacks that return a promise.

fixes #24005
fixes JS-3560

Co-Authored-By: yaoxp <viq_xp@126.com>
@linear-code

linear-code Bot commented Sep 3, 2026

Copy link
Copy Markdown

JS-3560

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.69 kB - -
@sentry/browser - with treeshaking flags 26.99 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.89 kB - -
@sentry/browser (incl. Tracing) 49.07 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 49.07 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.98 kB - -
@sentry/browser (incl. Tracing, Replay) 88.55 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.85 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 93.24 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 106.18 kB - -
@sentry/browser (incl. Feedback) 46.17 kB - -
@sentry/browser (incl. sendFeedback) 33.75 kB - -
@sentry/browser (incl. FeedbackAsync) 38.85 kB - -
@sentry/browser (incl. Metrics) 29.66 kB - -
@sentry/browser (incl. Logs) 29.94 kB - -
@sentry/browser (incl. Metrics & Logs) 30.59 kB - -
@sentry/react 30.45 kB - -
@sentry/react (incl. Tracing) 51.28 kB - -
@sentry/vue 35.91 kB - -
@sentry/vue (incl. Tracing) 51.34 kB - -
@sentry/svelte 28.71 kB - -
CDN Bundle 30.43 kB - -
CDN Bundle (incl. Tracing) 49.6 kB - -
CDN Bundle (incl. Logs, Metrics) 32.66 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 51.53 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.25 kB - -
CDN Bundle (incl. Tracing, Replay) 87.1 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.97 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 93.03 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.97 kB - -
CDN Bundle - uncompressed 90.13 kB - -
CDN Bundle (incl. Tracing) - uncompressed 147.81 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.52 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 153.59 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.68 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 267.3 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 273.07 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 281 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 286.76 kB - -
@sentry/nextjs (client) 53.89 kB - -
@sentry/sveltekit (client) 49.51 kB - -
@sentry/core/server 40.96 kB - -
@sentry/core/browser 13.53 kB - -
@sentry/node 124.66 kB +0.02% +21 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.51 kB - -
@sentry/node - without tracing 88.5 kB +0.03% +23 B 🔺
@sentry/node - without channel injection 103.95 kB +0.03% +22 B 🔺
@sentry/aws-serverless 96.87 kB +0.03% +23 B 🔺
@sentry/cloudflare (withSentry) - minified 201.56 kB - -
@sentry/cloudflare (withSentry) 501.37 kB - -

View base workflow run

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.

makeOfflineTransport awaits a synchronous shouldSend, delaying transport.send() by a microtask

1 participant