Skip to content

Race condition when waiting for isReady() after signalReady() was already called #210

Closed
@Lootwig

Description

@Lootwig

The code below throws an exception (including a typo): "Unhandled Exception: Bad state: There are still other objects waiting for this instance so signal ready"

Since it's unpractical to guarantee the order in which calls to isReady / signalReady are executed when instances are distributed over the entire project, maybe the objectsWaiting.add(...) calls should be ignored after an instance already signaled to be ready once?

class X {}

void main() async {
  var x = X();
  GetIt.I.registerSingleton(x, signalsReady: true);
  GetIt.I.signalReady(x);
  await GetIt.I.isReady<X>();
  GetIt.I.unregister<X>();
}

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