Skip to content

scale: getNextId repeats fleet IDs beyond the safe integer range #949

Description

@aiirvizionz

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:

inst-9007199254740992

The returned ID is identical to the existing ID.

Expected

The next ID should be exact and unique:

inst-9007199254740993

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.

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