Open lwouis opened 5 years ago
To avoid us having to try and replicate your project's setup and/or go through the motions of setting up firebase, can you share with us the project or create a reproduction of the issue?
This will speed up our ability to triage and patch.
I would love to find a workaround even if it means I can ignore those firebase calls and mock the other calls
In the meantime, have you tried to intercept the firestore/firebase calls and mock a response? i.e.,
polly
.server
.get('https://firestore.googleapis.com/*')
.intercept((req, res) => res.sendStatus(200));
@jasonmit I made a public repo to reproduce. Just git clone it and run npm start
to witness the issue. If you comment out lines 22-34 in app.component.ts
which correspond to Pollyjs instanciation, you will see the correct behaviour
It seems there are many layers involved.
zone.js (required by angular) is extending the original, native, XHR object and this is done before Polly replaces the global XHR object.
After fixing that, I noticed firestore aborts the XHR requests after 30s and creates a new request. However, when dealing with Polly the fakeXhr instances have a readyState
of 1 ("opened") at the time they're being aborted. With Polly disable, the native XHR instances have a readyState
of 4 ("done") at the time abort is called. I'd like to figure out why this is, should help us understand what needs patched.
I'll need to circle back once I have more cycles to devote again.
Description
I'm using Firestore in my project. Firestore seems to use long-polling on HTTP GET requests to provide its real-time updates. This means firestore js library (i'm using angularfire2) first makes a POST request to firestore servers. That one is fine. Then it does a GET request, which is kept open for a long time, around a minute. If you look at that GET request in Chrome's devtool, it will show you an empty response because devtools are waiting for the request to close I guess to display the response. However the js code already has access to the chunks of data, so firebase already displays it on the page.
When polly.js gets in the picture, even in passthrough mode, it crashes. The POST request works fine, but the subsequent long-lived GET queries, even if passed-through, are breaking firebase js call-site.
The fact that passthrough also breaks firestore means it's a no-go for my project. I'm really eager to use polly.js, and I would love to find a workaround even if it means I can ignore those firebase calls and mock the other calls. Best would be of course to be able to mock those long-polling calls as well.
Error Message & Stack Trace
In order:
At this point, the GET request is intercepted by polly.js, but polly is not logging it cause the request is still not closed.
After 10s, firebase call-site which is wrapped by polly fails to get the data they want, so they print this:
After more time, like 1min, the request is closed (I assume by the server), and polly prints:
I think this class may be the firestore network implementation.
Config
Copy the config used to setup the Polly instance:
Dependencies
Copy the @pollyjs dependencies from
package.json
:Environment
This is running in-browser