Skip to content

Conversation

mydea
Copy link
Member

@mydea mydea commented Sep 15, 2025

We make quite heavy use of it in event processing, not touching this for now, but in other places it should not be needed IMHO. These are all places that will never be sync generally speaking so it is fine to make them "proper" async.

Somewhat related to #17634

@mydea mydea self-assigned this Sep 15, 2025
Copy link
Contributor

github-actions bot commented Sep 15, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 24.15 kB -0.03% -5 B 🔽
@sentry/browser - with treeshaking flags 22.73 kB +0.02% +3 B 🔺
@sentry/browser (incl. Tracing) 40.16 kB +0.02% +5 B 🔺
@sentry/browser (incl. Tracing, Replay) 78.53 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 68.25 kB +0.02% +7 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 83.2 kB +0.01% +3 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 95.39 kB -0.01% -3 B 🔽
@sentry/browser (incl. Feedback) 40.87 kB -0.03% -9 B 🔽
@sentry/browser (incl. sendFeedback) 28.81 kB - -
@sentry/browser (incl. FeedbackAsync) 33.74 kB -0.04% -11 B 🔽
@sentry/react 25.88 kB -0.02% -5 B 🔽
@sentry/react (incl. Tracing) 42.17 kB +0.01% +1 B 🔺
@sentry/vue 28.64 kB +0.01% +2 B 🔺
@sentry/vue (incl. Tracing) 41.98 kB +0.01% +2 B 🔺
@sentry/svelte 24.19 kB -0.02% -4 B 🔽
CDN Bundle 25.74 kB -0.01% -1 B 🔽
CDN Bundle (incl. Tracing) 40.03 kB -0.05% -18 B 🔽
CDN Bundle (incl. Tracing, Replay) 76.25 kB -0.02% -14 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) 81.76 kB -0.03% -19 B 🔽
CDN Bundle - uncompressed 75.21 kB +0.05% +36 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 118.54 kB +0.04% +36 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 233.67 kB +0.03% +62 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 246.43 kB +0.03% +62 B 🔺
@sentry/nextjs (client) 44.15 kB - -
@sentry/sveltekit (client) 40.6 kB +0.01% +3 B 🔺
@sentry/node-core 49.86 kB -0.01% -4 B 🔽
@sentry/node 151.14 kB -0.01% -14 B 🔽
@sentry/node - without tracing 91.74 kB -0.01% -4 B 🔽
@sentry/aws-serverless 105.18 kB -0.01% -10 B 🔽

View base workflow run

Copy link
Contributor

github-actions bot commented Sep 15, 2025

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 9,505 - 9,114 +4%
GET With Sentry 1,353 14% 1,436 -6%
GET With Sentry (error only) 6,009 63% 6,318 -5%
POST Baseline 1,194 - 1,222 -2%
POST With Sentry 513 43% 536 -4%
POST With Sentry (error only) 1,051 88% 1,069 -2%
MYSQL Baseline 3,285 - 3,407 -4%
MYSQL With Sentry 390 12% 539 -28%
MYSQL With Sentry (error only) 2,673 81% 2,785 -4%

View base workflow run

@mydea mydea force-pushed the fn/avoid-sync-promise branch from 9038bfe to 77dd72e Compare September 15, 2025 13:50
@mydea mydea force-pushed the fn/avoid-sync-promise branch 2 times, most recently from 241d7cf to 61a0aa7 Compare September 16, 2025 09:13
mydea added a commit that referenced this pull request Sep 16, 2025
This changes our fetch transport a bit, making use of async functions
and slightly adjusting error handling:

1. Technically there was a bug if fetch is not available, as we would
keep increasing the `pendingBodySize`/`pendingCount` and never decrease
it.
2. We had some dedicated error messages for edge cases that are IMHO not
necessary - we can safe a few bytes by just using default error messages
there.
3. No need to use sync promise here, all of this is async anyhow.

Extracted this out of
#17641
mydea added a commit that referenced this pull request Sep 16, 2025
I noticed that we actually handled errors in `sendEnvelope` incorrectly
- we would resolve this function with the rejection reason, if sending
fails. this does not match the type of `TransportMakeRequestResponse`,
you could actually get something like this out (and the tests actually
incorrectly tested this):

```js
// transport.send() rejects with "fetch does not exist"
const res = await client.sendEnvelope(envelope);
// res --> "fetch does not exist" (string)
```

This PR fixes this to instead resolve with an empty object (which
matches the expected return type).

Extracted this out of
#17641 because it is
actually a bug/fix.
@mydea mydea force-pushed the fn/avoid-sync-promise branch 2 times, most recently from 59eeb61 to b6c7507 Compare September 17, 2025 06:48
@mydea mydea requested review from Lms24 and s1gr1d September 17, 2025 08:46
@mydea mydea marked this pull request as ready for review September 17, 2025 08:46
@mydea mydea requested a review from a team as a code owner September 17, 2025 08:46
We make quite heavy use of it in event processing, not touching this for now, but in other places it should not be needed IMHO.

fix transport using async

refactor some more sync promise stuff

fix node client

fix some flushing stuff

fix check oops

small fixees

fix tests

fix lint

fix to promise like

small ref

avoid special casing of no fetch implementation

fetch stuff
@mydea mydea force-pushed the fn/avoid-sync-promise branch from b6c7507 to 3bc8532 Compare September 17, 2025 08:47
Comment on lines +319 to +320
// @ts-expect-error - PromiseLike is a subset of Promise
public async flush(timeout?: number): PromiseLike<boolean> {
Copy link
Member

Choose a reason for hiding this comment

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

So for a moment, I thought the async signature change would still be breaking for anyone currently extending Client and overriding this method (as in, them not having the async declaration). But it seems like this is fine (at least with the TS settings in our repo) and TS is smart enough to handle it. Just wanted to leave this thought here in case we can think of a TS setting or a scenario where this might be problematic.

Co-authored-by: Lukas Stracke <[email protected]>
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.

2 participants