Skip to content

Conversation

@mjfaga
Copy link
Collaborator

@mjfaga mjfaga commented Aug 26, 2025

Description

Ported from prefab-cloud/prefab-cloud-node#108

Fixes a JavaScript precision issue where large config IDs lose accuracy during telemetry reporting. Config ID 17537369033474523 was being reported as 17537369033474524 due to JavaScript's number precision limits.

Root Cause:

The telemetry system serializes evaluation data to JSON for aggregation, then deserializes it before sending to the API. During JSON.parse(), numeric strings in arrays are automatically converted to JavaScript numbers. For integers larger than Number.MAX_SAFE_INTEGER (2^53 - 1), this causes precision loss.

The Fix:

Changed Long.fromNumber(configId) to Long.fromString(configId) in the telemetry counter deserialization logic. This preserves the exact string representation throughout the JSON round-trip, avoiding JavaScript number precision issues.

Testing

  • Added regression test that verifies config ID 17537369033474523 is preserved exactly during telemetry processing
  • All existing telemetry tests continue to pass
  • Full test suite passes (519 tests)
  • Lint and format checks pass

The fix is minimal and targeted, only affecting the specific conversion point where precision was being lost.

@mjfaga mjfaga requested a review from jkebinger August 26, 2025 01:56
@mjfaga mjfaga enabled auto-merge August 26, 2025 01:57
Copy link
Contributor

@jdwyah jdwyah left a comment

Choose a reason for hiding this comment

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

thank you

@mjfaga mjfaga merged commit 4501e78 into main Aug 26, 2025
2 checks passed
@mjfaga mjfaga deleted the mfaga-port-fix branch August 26, 2025 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants