Requests randomly failing

I have this weird problem where some requests fails randomly. It’s been 3 days I struggle with this and I have no more idea what can cause this behavior. Sometimes it is images not loading and sometimes it is ajax request (cfs/severtime or algolia-search) and some other times everything is fine. It also happen in local and online. Here are two different screenshots where different resources fails to load after refreshing the browser.

I have screenshots of my Chrome Inspector > Network to show but I can’t attach it because I’m a new user…

Thanks !!

A few more ideas in case you have not tried these:

For completely inscrutable errors you may want to build a minimal app with just the stuff necessary to break things. i.e. start with what you have now, in a new folder/repo, strip away pieces bit by bit, until you either a) can’t strip it down any more or else you don’t get the problem any more or b) understand what’s actually going on.
Usually it’s high complexity that keeps us from seeing what’s actually going on and might be breaking.

Now, it may also be an actual problem in a library or Meteor itself etc. In that case you’d need to up your debugging tools game, e.g. bring in a network proxy/sniffer (can’t recommend one), begin debugging the code being executed from start to finish. You have the whole source of all packages involved available so it’s possible.

It’s usually almost impossible to spend more than a few hours on a single problem without progress, except if completely sticking around in confusion, stumbling in the dark. If that happens be sure to step away before such an incident eats a whole week or more… :smile:

And a few questions:
Does “local” mean using just meteor to run the app? What deployment process / env do you use for “online”?
There’s one weird bug that if you use nginx on Mac OS (in front of the app, or in front of anything, really) and have the sendfile option on it also gives you all kinds of weird errors; but your description doesn’t sound like this would be a good explanation for the observed behavior.

Also: Put your images on Dropbox, make them public and share the links here. Or use another image hosting service (even imgur works for this I think).

Thanks for you answer. Actually, I did step away from this problem for a couple days and I did create a new project as well as stripping out pieces bit by bit. Here is the stackoverflow orignal question, images are accessible from there.

I still keep error saying I can’t post more then 2 link or post images (even if it is an url)

stackoverflow.com/questions/30851292/meteor-requests-randomly-failing

1 Like

Finally found the source of my problem maybe my answer would help other Meteor developers.

I used to do this :

var providersSub = Meteor.subscribe('providers');

Tracker.autorun(function () {
  if(!providersSub.ready())
    return;

  var providerIds = _.pluck(Provider.all().fetch(), '_id'));      
  ...
  this.stop();
});

Instead of :

var providersSub = Meteor.subscribe('providers');
 
Tracker.autorun(function (computation) {
  if(!providersSub.ready())
    return;

  var providerIds = _.pluck(Provider.all().fetch(), '_id'));      
  ...
  computation.stop();
});

The this in a tracker function is actually the Window object so I was calling Window.stop() which is the same as clicking the stop button in the browser. :unamused:

Whoopsie :wink: Post your code next time along with your question because it’s very likely myself or someone else would have spotted the mistake almost instantaneously. After a while one’s sense for what this means in any given “Meteor-context” is pretty good, having gone through a whole bunch of those silly mistakes in the early days! :smile:

Glad you solved it!