Explanation and solutions to process long OrderID (U-M futures) in JS

Q:
Why do I get below errors when trying to cancel a U-M futures order using orderId
Error:

{ code: -2011, msg: 'Unknown order sent.' }

A:
If you use JS and you get above error when you try to cancel an open order using orderId, please check the orderID as an integer to see if it exceeds the maximum integer of JS using

console.log(Number.MAX_SAFE_INTEGER)

If it does, JS would make the last several digits zero (for e.g. 8389765489680951453 would become 8389765489680951000 and it would happen right after JSON.parse() so don’t be confused and think it’s the raw orderID); So when you send it back, the system cannot recognize it

Potential Solutions:

Use client order id to cancel this kind of orders
If you rely on websocket to capture the orderId, don’t JSON.parse it to an JSON object; Instead, use regex to capture the oderID as a string
There’s one npm called‘json-bigint’which could be used to parse a string to JSON. This is a 3rd-party solution so no guarantee of its stability
Currently known symbols are ETHUSDT & RSRUSDT & HNTUSDT

Sample code of using json-bigint:

var JSONbig = require('json-bigint');
let result = JSONbig.parse(<data string>);

Is it possible to add a new field orderIdStr to have the order ID as a string? It is fragile and error-prone regex the ID… I assume similar treatment could be applied to tradeId as well.