repeaterjs / repeater

The missing constructor for creating safe async iterators
https://repeater.js.org
MIT License
459 stars 12 forks source link

Event loop can die if stop() not called #75

Open jedwards1211 opened 1 year ago

jedwards1211 commented 1 year ago

Opening a separate issue from #49 for the sake of people googling why their process is just dying on them.

It seems a bit too easy to accidentally cause the event loop to die:

const { Repeater } = require('@repeaterjs/repeater')

const test = new Repeater((push, stop) => {
  push(1)
  // stop()
})

;(async () => {
  for await (const value of test) {
    console.log(value)
  }
  // event loop dies before this point unless you uncomment stop() above
  console.log('done')
})()
andrewmclagan commented 2 months ago

yep encountered this behaviour after many hours ended up here.