Skip to content

Conversation

@malay44
Copy link
Contributor

@malay44 malay44 commented Dec 10, 2025

Track in-flight metrics when flushing and include them in the drop limit check to prevent unbounded growth when network sends are slower than metric production.

Closes #18080
Closes JS-1107

malay44 and others added 2 commits December 10, 2025 21:48
Track in-flight metrics when flushing and include them in the drop limit
check to prevent unbounded growth when network sends are slower than
metric production.
@JPeer264
Copy link
Member

For me, the implementation looks great thanks, you can ignore the failing "Size check" action for now. Let's wait for @chargome on this PR

@JPeer264 JPeer264 requested a review from chargome December 11, 2025 09:48
@malay44 malay44 marked this pull request as ready for review December 12, 2025 12:11
// sendEnvelope should not throw
// eslint-disable-next-line @typescript-eslint/no-floating-promises
client.sendEnvelope(envelope);
client.sendEnvelope(envelope).then(() => _setInFlightCount(client, count => count - metricsCount));
Copy link

Choose a reason for hiding this comment

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

Bug: In-flight count leaks if sendEnvelope promise rejects

The in-flight count decrement uses .then() without a .catch() or .finally(). If sendEnvelope rejects for any reason (despite the comment saying it shouldn't throw), the callback never runs and metricsCount is never subtracted from the in-flight counter. This causes a permanent leak where the in-flight count stays artificially high, leading to future metrics being incorrectly dropped due to the inflated total. Using .finally() instead would ensure the count is always decremented regardless of promise resolution or rejection.

Fix in Cursor Fix in Web

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.

Add limit for metric aggregation

2 participants