If we try to bulk generate multiple snowflake IDs concurrently from the same machine, all the IDs are same:
const generateSnowflakeId = (machineId = null) => {
const config = {
instance_id: machineId,
custom_epoch: new Date("2001-01-01").getTime(),
};
const uid = new Snowflake(config);
const snowflakeId = uid.getUniqueID();
return snowflakeId;
};
const COUNT = 10;
const CURRENT_MACHINE_ID = 1; // Assumed
const snowflakeIds = [];
for (let i = 0; i < COUNT; i++) {
const snowflakeId = generateSnowflakeId(CURRENT_MACHINE_ID);
snowflakeIds.push(objectId);
}
All the IDs are the same. Am I doing something incorrectly?
Node.js version: 16.17 and 18.17
Package version: 2.0.1