Description
Symptoms
The message body of failed message is incorrectly displayed if it contains a value larger than JavaScript's Number.MAX_VALUE
Who's affected
All users of ServicePulse who have message bodies with large numbers in a message property
Root cause
JavaScript has a maximum value for numbers, and JSON can only represent numbers as a number type, not the more recently introduced bigint. Any number in a serialized message larger than number.MAX_VALUE will therefore be rounded to the nearest base order of magnitude value when deserialized to JSON.
Description
When attempting to view the message body of a failed message containing a large number in ServicePulse, the displayed number appears incorrect.
For instance, a JSON object like { "x": 10000000000000001 } is displayed as { "x": 10000000000000000 }. Moreover, upon editing and retrying the message with changes to unrelated values, the incorrectly displayed value for 'x' (ending in 0) persists.
This happens for any number bigger than Number.MAX_SAFE_INTEGER on javascript.
Expected behavior
The large number within the message body should be accurately displayed, without any alteration or truncation.
Actual behavior
The large number is displayed incorrectly, rounded down, leading to potential data misinterpretation.
Versions
All
Steps to reproduce
- Send a message containing a large number (e.g., { "x": 10000000000000001 }) through the system.
- Encounter a failure and attempt to view the message body in ServicePulse.
Relevant log output
No response
Additional information
- The issue is likely related to the inherent limitations of double precision floating-point representation used by JavaScript/JSON for such large values.
- Despite the display issue in ServicePulse, NServiceBus and C# are capable of handling the serialization and deserialization of these values without errors, which for us means the display issue is unintended.