Skip to content

fix(inspector): Preserve floating point precision from inspector response #1141

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

Conversation

Tango992
Copy link
Contributor

@Tango992 Tango992 commented Jun 8, 2025

Fixes denoland/deno#29059

Messages from the inspector that hold a number value can result in the loss of floating point precision when deserialized.

When a user sends 0.9999999999999999 in the REPL, V8 returns a RemoteObject that contains the field "value": 0.9999999999999999. However, when it's deserialized into serde_json::Value here:

deno_core/core/inspector.rs

Lines 883 to 884 in fc1ef37

let message: serde_json::Value =
match serde_json::from_str(&inspector_msg.content) {

value becomes serde_json::Number(1.0), causing the REPL to print 1. Enabling the float_roundtrip feature flag of serde json resolves this.

Before:
Screenshot_20250608_182040

After:
Screenshot_20250608_202822-1

@CLAassistant
Copy link

CLAassistant commented Jun 8, 2025

CLA assistant check
All committers have signed the CLA.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.69%. Comparing base (0c7f83e) to head (db8bd12).
Report is 307 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1141      +/-   ##
==========================================
+ Coverage   81.43%   81.69%   +0.25%     
==========================================
  Files          97      100       +3     
  Lines       23877    28957    +5080     
==========================================
+ Hits        19445    23657    +4212     
- Misses       4432     5300     +868     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, sweet fix 👍

@bartlomieju bartlomieju merged commit 4bd4cd3 into denoland:main Jun 8, 2025
18 checks passed
@Tango992 Tango992 deleted the preserve-float-precision-from-inspector-response branch June 9, 2025 01:10
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.

Repl prints n = 0.9999999999999999 as 1 (even though n != 1 in IEEE 754)
4 participants