javascript - How do I simulate multiple simultaneous slow Meteor publications? -
i want simulate multiple slow subscriptions. client subscribes 2 or more publications @ same time, , result arrive later.
goal able see how network latencies , randomness can affect application (it bugs because expected publication ready before another, ...).
using following short setup publications:
// server/foo.js meteor.publish('foo', function() { console.log('publishing foo'); meteor._sleepforms(2000); console.log('waking foo'); this.ready(); }); // server/bar.js same different name meteor.publish('bar', function() { console.log('publishing bar'); meteor._sleepforms(2000); console.log('waking bar'); this.ready(); });
both publications slowed down meteor._sleepforms
seen in this amazing answer.
the client subscribes each publication:
meteor.subscribe('bar'); // /client/bar.js meteor.subscribe('foo'); // /client/foo.js
from there expected see both 'publishing'
logs first, both 'waking up'
.
however, appears in console:
15:37:45? publishing bar
15:37:47? waking bar
15:37:47? publishing foo
15:37:49? waking foo
(i removed irrelevant fluff day)
so runs in synchronous fashion. thought 2 things can cause that: server waitforms
entirely block server (fairly weird), or client subscription design.
to make sure wasn't server added simple heartbeat:
meteor.setinterval(function() { console.log('beep'); }, 500);
and did not stop beeping, server isn't blocked.
i suspect issue lies within client subscription model, maybe waits subscription ready before calling another..?
thus, 2 questions:
- why doesn't experiment run way wanted to?
- how should modify achieve desired goal (multiple slow publications) ?
meteor processes ddp messages (which include subscriptions) in sequence. ensures can perform action deleting object , inserting in correct order, , not run errors.
there support getting around in meteor.methods
using this.unblock()
allow next available ddp message process without waiting previous 1 finish executing. unfortunately not available meteor.publish
in meteor core. can see discussion (and workarounds) issue here: https://github.com/meteor/meteor/issues/853
there package adds functionality publications:
Comments
Post a Comment