-
-
Notifications
You must be signed in to change notification settings - Fork 35
Description
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;
}