Skip to content
This repository was archived by the owner on May 18, 2026. It is now read-only.
This repository was archived by the owner on May 18, 2026. It is now read-only.

possible race condition if setup of event listeners is delayed? #14

@bpow

Description

@bpow

I may just not be used to node/javascript idioms, but I think there is a race condition since there is no way to make sure that the event listeners are set up before events start getting triggered.

For instance, something like the following:

var VCF = require('./lib/index')

var allFeatures = []

var v = VCF.read('test/sample.vcf')

setTimeout(function () {
  v.on('data', (f) => allFeatures.push(f))
  v.on('end', () => console.log(allFeatures))
}, 1000)

will not write out any data because the vcf object emits all of its 'data' events before the 'data' listener is setup. But if the delay parameter (1000) is changed to '0', then the 'data' and 'end' listeners are setup in time.

I don't know if this is a problem in the real-world (if the .on('data'... directly follows the .read call, then maybe there is no way for the race to occur?)

Apologies if I just mis-understand the idiom.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions