mcollina/hyperid

getting stuck at "/undefined" as part of id...

osher opened this issue · 1 comments

osher commented

I ran this simple experiment:

> id = require('hyperid')({ fixedLength: true })
[Function: generate] {
  uuid: '3ec503a9-6dd2-4f53-b85f-380d08ccda74',
  decode: [Function: decode]
}
> i = 0; while (++i < 100000000000 ) { 0 == i % 1000000 ?  console.log( id() )  : id () }
apJUntnyRUagA934HnZreg/0000999999
apJUntnyRUagA934HnZreg/0001999999
apJUntnyRUagA934HnZreg/0002999999
apJUntnyRUagA934HnZreg/0003999999
apJUntnyRUagA934HnZreg/0004999999
apJUntnyRUagA934HnZreg/0005999999
...

which ended sadly with:

apJUntnyRUagA934HnZreg/0993999999
apJUntnyRUagA934HnZreg/0994999999
apJUntnyRUagA934HnZreg/0995999999
apJUntnyRUagA934HnZreg/0996999999
apJUntnyRUagA934HnZreg/0997999999
apJUntnyRUagA934HnZreg/0998999999
apJUntnyRUagA934HnZreg/0999999999
apJUntnyRUagA934HnZreg/undefined
apJUntnyRUagA934HnZreg/undefined
apJUntnyRUagA934HnZreg/undefined
apJUntnyRUagA934HnZreg/undefined
apJUntnyRUagA934HnZreg/undefined
^CUncaught Error: Script execution was interrupted by `SIGINT`

woups?

ubuntu, node 12.

osher commented

if you

 var count = opts.startFrom

instead

 var count = 0

it makes it easily tested and reproduced in no time.
mmm.. let me start a PR on this...