Skip to content

DDP events may only be consumed after AppState change on iOS #167

Description

@bratelefant

Describe the bug
It may happen, that after a method call, the resulting update and result DDP messages are being received, but the corresponding ddp events are not being processed in the client event queue.

To Reproduce
I'm afraid I have no working example project to reproduce this yet; also in my production app, this occurs in only a few components. First occurence was after migration to react navigation v7 from v6. It is a component simply fetching data from meteor 3.2.0 server via a single method call.

Expected behavior
All incoming messages trigger an event instantly.

Screenshots
n/A

Possible solution
I changed a few lines in lib/ddp.js in order to change the way the emit method defers calling the EventEmitter.emit method by defering it to a microtask rather than a macrotask, so that the event will be emitted before the next frame renders.

before

emit() {
    setTimeout(super.emit.bind(this, ...arguments), 0);
  }

after

emit(...args) {
    Promise.resolve().then(() => super.emit(...args));
    return true;
  }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions