-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(core): Add a PromiseBuffer for incoming events on the client #18120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
619a016 to
1695dd4
Compare
| processEvent(event: Event): Event | null | PromiseLike<Event | null> { | ||
| return new Promise(resolve => setTimeout(() => resolve(event), 1)); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Async Test Integration Missing Event Processor Setup
The AsyncTestIntegration defines a processEvent method but lacks a setupOnce or setup method to register it as an event processor. Without registration, the async processEvent won't execute, causing tests using this integration to pass incorrectly without actually exercising the promise buffer's async event handling logic.
1695dd4 to
2ee14b4
Compare
size-limit report 📦
|
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.
|
Problem
Previously, the client would process all incoming events without any limit, which could lead to unbounded growth of pending events/promises in memory. This could cause performance issues and memory pressure in high-throughput scenarios. This occurs when two conditions are met:
processEventare added (e.g.ContextLines, which is a defaultIntegration)Sentry.captureException, are called synchronouslySolution
This PR adds a
PromiseBufferto theClientclass to limit the number of concurrent event processing operations._promiseBufferin theClientclass that limits concurrent event processingDEFAULT_TRANSPORT_BUFFER_SIZE(64) but can be configured viatransportOptions.bufferSizequeue_overflowreason_process()method to:Special 👀 on
transportOptions.bufferSize: Not sure if this is the best technique, but IMO both should have the same size - because if it wouldn't it would be capped at a later stage (asking myself if the transport still needs the promise buffer - as we have it now way earlier in place)_processtakes now aDataCategory. At the time of the process the event type is almost unknown. Not sure if I assumed the categories correctly there, or if there is another technique of getting the type (edit: a comment by Cursor helped a little and I added a helper function)recordDroppedEventis now printing it one after each other - theoretically we can count all occurences and print the count on it. I decided against this one, since it would delay the user feedback - this can be challenged though