Skip to content

Unexpected Re-entrant behavior #574

Open
@Macil

Description

@Macil

Several days of debugging an issue have finally led me to discovering this:

var Bacon = require('baconjs');

var criticalSectionActive = false;
var someBus = new Bacon.Bus();
someBus.log();

Bacon.later(0, [1,2])
  .flatMap(Bacon.fromArray)
  .onValue(function(x) {
    if (criticalSectionActive) {
      console.error("Re-entrance!", x);
    }
    criticalSectionActive = true;
    someBus.end();
    criticalSectionActive = false;
    console.log('got x', x);
  });

Output:

<end>
Re-entrance! 2
got x 2
got x 1

Expected output:

<end>
got x 1
got x 2

Using Bacon 0.7.53

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