xolvio / meteor-http-interceptor

Intercepts HTTP calls and allows fake implementations to take over entire domains. Used for testing.
13 stars 5 forks source link

`meteor add xolvio:http-interceptor` causes massive client failures (App specific) #10

Open revbucket opened 7 years ago

revbucket commented 7 years ago

I'm seeing a strange error determined by the presence/absence of xolvio:http-interceptor.

Let's start with the base (non-broken) case: My meteor app doesn't have the 'http-interceptor' added to it, and running it locally with the standard $ meteor run hosts the app on localhost:3000 as expected. Nothing is printed in the client console.

Then when pause the app, add http-interceptor, and restart, I get the exact same logs printed to the server, but nothing renders on the client and I get a bunch of errors. See the gist here: https://gist.github.com/revbucket/7b92eca261b30e3d6bfc31f2e8c5df2b which has a copy/paste of all the errors from Chrome as well as a copy/paste of the output of $ meteor list

Some extra debugging info: 1) I tried to replicate this error on the meteor example apps, and was unable to do so. Though the presence/absence of http-interceptor determined the presence/absence of this console printout on loading localhost:3000 of the meteor Todos example app:

Exception in template helper: ReferenceError: Session is not defined
    at Object.shouldShow (http://localhost:3000/packages/xolvio_http-interceptor.js?hash=973c6760402153debb8c7f8db623d414b30ab2d2:157:12)
    at http://localhost:3000/packages/blaze.js?hash=a9372ce320c26570a2e4ec2588d1a6aea57de9c1:2994:16
    at http://localhost:3000/packages/blaze.js?hash=a9372ce320c26570a2e4ec2588d1a6aea57de9c1:1653:16
    at http://localhost:3000/packages/blaze.js?hash=a9372ce320c26570a2e4ec2588d1a6aea57de9c1:3046:66
    at Function.Template._withTemplateInstanceFunc (http://localhost:3000/packages/blaze.js?hash=a9372ce320c26570a2e4ec2588d1a6aea57de9c1:3687:12)
    at http://localhost:3000/packages/blaze.js?hash=a9372ce320c26570a2e4ec2588d1a6aea57de9c1:3045:27
    at Object.Spacebars.call (http://localhost:3000/packages/spacebars.js?hash=45ae773bea8216022dfca4f7eb46d878e5336593:172:18)
    at Template.httpCalls.Blaze.If.HTML.DIV.class (http://localhost:3000/packages/xolvio_http-interceptor.js?hash=973c6760402153debb8c7f8db623d414b30ab2d2:59:22)
    at Blaze.View.<anonymous> (http://localhost:3000/packages/blaze.js?hash=a9372ce320c26570a2e4ec2588d1a6aea57de9c1:2677:44)
    at http://localhost:3000/packages/blaze.js?hash=a9372ce320c26570a2e4ec2588d1a6aea57de9c1:1875:20

2) I cloned http-intercept into my app's local packages directory so I could drop console.logs everywhere, and it looks like everything on the server side loads.

3) It looks like with the presence of http-interceptor the requests meteor makes internally fail (as viewed within the developer-tools.network tab on your browser), [e.g. http://localhost:3000/merged-stylesheets.css?hash=9a1180330f03ef4fe7a0dd41cec27d51db1d9d7b] .

I'm not comfortable sharing the source code of the entire app, but I can provide more info if requested

stijndepestel commented 7 years ago

I have encountered the same problem. From what I have seen from your gist I guessed that it was the combination of the iron:router (which is used internally by the http-interceptor) and the kadira:flow-router which you use in your application which causes the problem.

I have created a fork in which I switched from the iron:router to the meteorhacks:picker server side router, which solved the problem for me.

You can find the code here: stijndepestel:http-interceptor. I have also pushed it to the atmosphere index as stijndepestel:http-interceptor.

Hopefully you can use it to solve your problem!

workflow commented 7 years ago

This is like the worst bug to nail down in the universe! Holy sh**t. We got it when upgrading from Meteor 1.3.5.1 to Meteor 1.4.2.3 and were suddenly seeing errors just like yours on the client:

Failed to load resource: net::ERR_CONTENT_DECODING_FAILED
es5-shim.js:17 Uncaught TypeError: Cannot read property 'meteorInstall' of undefined
    at es5-shim.js:17
    at es5-shim.js:2789
Uncaught TypeError: Cannot read property 'meteorInstall' of undefined
    at promise.js:17
    at promise.js:581
Uncaught TypeError: Cannot read property 'meteorInstall' of undefined
    at ecmascript-runtime.js:17
    at ecmascript-runtime.js:4630
...

Needless to say, with the big upgrade just made, there were too many vectors. With a monolith our size, this could have taken days to debug.

I'm utterly thankful @revbucket @stijndepestel for having stumbled upon this :) absolutely made our day! :beers: :beers: