Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(auth): slow performance of auth process with react-redux-firebase #213

Open
alexandermckay opened this issue Oct 27, 2020 · 10 comments
Open
Labels
needs-repro Needs reproduction steps

Comments

@alexandermckay
Copy link

Describe the bug
When using cypress-firebase with react-redux-firebase the auth process takes a minimum of 5 seconds. There is an enormous length of time between the @@reactReduxFirebase/AUTHENTICATION_INIT_FINISHED action being fired and the next action @@reactReduxFirebase/LOGIN/@@reactReduxFirebase/AUTH_EMPTY_CHANGE being triggered. This delay does not exist when using plain Chrome.

The only way I have been able to get my tests to pass is to increase defaultCommandTimeout to 10000, which is not ideal. I have tried my tests on two different internet speeds (8mbs/14mbs) and the results were almost identical. Additionally, if I open up the dev server in plain chrome rather than in a cypress test the auth process is <0.3s. I am confused as to why running the process through cypress instead of chrome increases the time the process takes by >10 times.

To Reproduce
Steps to reproduce the behavior:

To make this issue easier to replicate I have created a repo here.

Expected behavior/code
For the@@reactReduxFirebase/AUTH_EMPTY_CHANGE call to fire in the same amount of time in plain Chrome/ cypress controlled Chrome. The two screenshots below were taken on the same computer, about 10 seconds apart.

Chrome - 00.27 seconds
Screen Shot 2020-10-27 at 1 39 01 pm

Cypress - 05.67 seconds
Screen Shot 2020-10-27 at 1 40 49 pm

@alexandermckay alexandermckay changed the title Slow Performance of cy.login Slow Performance of auth process Oct 27, 2020
@alexandermckay alexandermckay changed the title Slow Performance of auth process Slow Performance of Auth Process Oct 27, 2020
@alexandermckay
Copy link
Author

@prescottprue

@prescottprue
Copy link
Owner

@alexandermckay thanks for the repro, I'll try to look into it this weekend - wondering if it has to due with when the app boots up vs when the form is being filled out

Something of note is that this should only really impact tests for your authentication - other tests you should be able to be using cy.login which auths the user with a custom token so you don't have to go through the login UI each time (aligned with Cypress best practices)

@prescottprue prescottprue changed the title Slow Performance of Auth Process Slow Performance of Auth Process with react-redux-firebase Nov 12, 2020
@alexandermckay
Copy link
Author

@prescottprue I am using cy.login for a majority of my tests. However, this still takes ~5 seconds to execute the @@reactReduxFirebase/LOGIN redux action.

Love the library by the way!

@alexandermckay
Copy link
Author

@prescottprue did you get a chance to look at the issue over the weekend?

@prescottprue
Copy link
Owner

I haven't yet, had some stuff come up. Quick question though, are you by chance using Firestore? From the actions in your screenshot, I am assuming you are since I see redux-firestore - if so have you set experimentalForceLongPolling = true; in your config?

I ask because there is a known issue with Firestore taking a long time with Cypress due to how web channels are being used, but enabling long polling in Firestore seems to fix that issue. That said, not sure that it would impact the speed at which the auth action is dispatched 🤔

@jonespen
Copy link
Contributor

jonespen commented Dec 9, 2020

Just chiming in here, I had a similiar issue, and resolved it using experimentalAutoDetectLongPolling: true instead of experimentalForceLongPolling: true after reading this issue. Seems like experimentalAutoDetectLongPolling might become default, so perhaps the docs should be updated to use this instead?

@alexandermckay
Copy link
Author

alexandermckay commented Dec 18, 2020

@jonespen what is performance like for your firestore emulator updates?

If I, for example, trigger a onClick={() => firestore.set({collection: 'posts', doc: 'foo'}, {title: 'Bar'})} call from my front-end during an E2E test, it takes ~3000ms before I am able to confirm the change has occurred with a cy.callFirestore('get', 'posts/foo').

Is that a typical wait time for you? If I am running the same test manually in Chrome rather than through Cypress the change occurs (practically) instantaneously.

@prescottprue what sort of wait times could be considered normal for cy.login + for changes triggered by front-end actions to create/update firestore?

@prescottprue
Copy link
Owner

A note on the issue @jonespen mentioned - I usually only enable the Firestore option when window.Cypress is defined (i.e. browser is the Cypress env)

@alexandermckay I don't see things take nearly that long at all - mine are often sub-second. So normal times for cy.login and changes: should be no more than a few seconds, and even that is "slow". Are you using either of the above mentioned config options with Firestore?

@prescottprue
Copy link
Owner

Ping - wondering if folks are still experiencing this with the mentioned config options enabled

@prescottprue prescottprue added the needs-repro Needs reproduction steps label May 2, 2021
@prescottprue prescottprue changed the title Slow Performance of Auth Process with react-redux-firebase bug(auth): slow performance of auth process with react-redux-firebase May 2, 2021
@prescottprue
Copy link
Owner

@alexandermckay and @jonespen Is anyone still experiencing this? I've had trouble replicating and the posted replication is no longer a valid link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-repro Needs reproduction steps
Projects
None yet
Development

No branches or pull requests

3 participants