Bug
getNextId converts numeric inst-* suffixes with Number.parseInt and increments them with Number arithmetic. Once an existing fleet ID exceeds JavaScript's safe integer range, that arithmetic can round the increment back to the same value and return a duplicate ID.
Reproduction
getNextId([{
id: 'inst-9007199254740992',
provider: 'aws',
status: 'running',
createdAt: '',
hourlyRate: 0.096,
}])
Current result:
The returned ID is identical to the existing ID.
Expected
The next ID should be exact and unique:
Proposed fix
Keep the numeric suffix as a BigInt while finding and incrementing the maximum, then convert it to a string for the final ID. This preserves the current inst-0001 formatting while avoiding precision loss.
Bug
getNextIdconverts numericinst-*suffixes withNumber.parseIntand increments them withNumberarithmetic. Once an existing fleet ID exceeds JavaScript's safe integer range, that arithmetic can round the increment back to the same value and return a duplicate ID.Reproduction
Current result:
The returned ID is identical to the existing ID.
Expected
The next ID should be exact and unique:
Proposed fix
Keep the numeric suffix as a
BigIntwhile finding and incrementing the maximum, then convert it to a string for the final ID. This preserves the currentinst-0001formatting while avoiding precision loss.