Skip to content

Detached generators don’t resume when reattached #144

@mbostock

Description

@mbostock

For example, given this generator:

const j = (async function* () {
  for (let j = 0; true; ++j) {
    yield j;
    await new Promise((resolve) => setTimeout(resolve, 1000));
  }
})();

If you reference the value of j like so:

The value of j is: ${j}.

Then everything works as expected. But, if you delete the reference to j, save, and then restore the reference to j, then j will resolve to undefined instead of incrementing once per second. I would guess that this has something to do with the generator being consumed lazily, and something bad is happening if there is no longer a downstream observer. 🤔

Metadata

Metadata

Assignees

Labels

bugSomething isn’t working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions