Thanks to visit codestin.com
Credit goes to github.com

Skip to content

HSET payload convert string to number, leading to precision loss in big number #662

@ImBIOS

Description

@ImBIOS

Related to:

log:

chat {
  msg: 'ping',
  userId: 363896575396806660,
  createdAt: 1697603525583,
  id: 'K0QjcRK',
}
userId 363896575396806667

script snippet:

const payload = {
        id,
        msg,
        userId, // it's string type
        createdAt,
      }
      console.log('payload', payload)
      await kv.hset(`chat:${id}`, payload) // but somehow here, it's converted to a number leading to a precision loss in the last digit

version:
"@vercel/kv": "^0.2.3",

Vercel masks Upstash's library, so I report it here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions