Skip to content

INCRBY return 'number', exceeding JavaScript's MAX_SAFE_INTEGER causes precision loss #2000

Closed

Description

@bian0726

I've encountered an issue related to data type handling for integer-based commands. Redis supports 64-bit signed integers, which can grow much larger than JavaScript's Number.MAX_SAFE_INTEGER (2^53 - 1).

Currently, commands like INCRBY return a standard JavaScript number. This can lead to a silent loss of precision when the integer value stored in Redis exceeds this limit. This is problematic for applications that rely on ioredis for accurate atomic counting with large numbers, such as leaderboards, distributed counters, or financial systems.

Thank you for your assistance.
Bob.

Activity

  1. nkaradzhov commented on Aug 7, 2025

    @nkaradzhov
    Contributor

    Hi @bian0726, thanks for reporting this issue! We are gonna look into it.

  2. PavelPashov commented on Aug 12, 2025

    @PavelPashov
    Contributor

    Hey @bian0726, you can enable the stringNumbers option and then parse the returned string

    export const redis = new Redis({
      stringNumbers: true,
    });
  3. bian0726 commented on Aug 13, 2025

    @bian0726
    Author

    @PavelPashov Thanks for the solution, I'll try using it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions