Repository navigation
fix: Prevent a NaN or infinite metric value from discarding all events in a flush - #498
Merged
keelerm84 merged 1 commit intoNov 20, 2026
Conversation
…ing the batch NaN and +/-Infinity metric values made JSON serialization raise, losing every event in the same flush. Signed-off-by: Alex Castillo <alex.castillog33@gmail.com>
2 of 3 tasks
keelerm84
approved these changes
Nov 20, 2026
Member
|
@pcbeingused333 thank you for contributing this fix! |
keelerm84
pushed a commit
that referenced
this pull request
Nov 20, 2026
🤖 I have created a release *beep* *boop* --- ## [8.20.1](8.20.0...8.20.1) (2026-11-20) ### Bug Fixes * Prevent a NaN or infinite metric value from discarding all events in a flush ([#498](#498)) ([2b0f4ef](2b0f4ef)) * Restart the stream when a delete event has a version that is not an integer ([#501](#501)) ([d060827](d060827)) * Signal readiness when selectorless initializers are exhausted ([#499](#499)) ([22fda02](22fda02)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requirements
Related issues
No issue in this repository. The same failure mode is addressed for the Go SDK in launchdarkly/go-sdk-events#69.
Describe the solution you've provided
LDClient#trackwith aNaNor±Infinitymetric value makes the whole event batch fail to serialize.CustomEvent#metric_valuegoes straight intoevents_out.to_json, which raisesJSON::GeneratorErrorfor non-finite floats. The error is rescued and logged inside the flush worker, buttrigger_flushhas already handed the payload over and cleared the outbox, so every other event in that flush (and the summary) is lost.EventProcessor#record_custom_eventnow logs a warning and drops only that custom event whenmetric_valueis a non-finiteFloat. Other events are untouched;datais not inspected.Three specs in
spec/events_spec.rb(NaN, +Infinity, -Infinity) record a healthy custom event plus a bad one and assert that only the healthy one is delivered. They fail without the change and pass with it.Reproduction:
Describe alternatives you've considered
metricValue: keeps the event but silently reports a different measurement.Additional context
This change was prepared with the assistance of an AI coding agent (Claude) and has not been reviewed line by line by a human prior to submission.
Note
Overview
Custom events with a NaN or ±Infinity
metricValueno longer break an entire flush batch.EventProcessor#record_custom_eventnow rejects non-finite Float metrics with a warning and skips enqueueing that event only.Specs cover NaN, +Infinity, and -Infinity: a valid custom event in the same flush still ships.
Reviewed by Cursor Bugbot for commit 705b7e3. Bugbot is set up for automated code reviews on this repo. Configure here.