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

Resolving requests times out #17

Open
kasperg opened this issue Jan 5, 2023 · 3 comments
Open

Resolving requests times out #17

kasperg opened this issue Jan 5, 2023 · 3 comments

Comments

@kasperg
Copy link

kasperg commented Jan 5, 2023

Thanks for sharing cypress-replay!

I tried it out in a project but with the latest version I get the following error when in record mode:

cy.then() timed out after waiting 10000ms.
Your callback function returned a promise that never resolved.
The callback function was:
() => requestCollection.resolveMap()

I cannot tell why this occurs. It seemed like request resolving was introduced with #14. I then tried to downgrade to the latest version before the change in #14, 1.0.14. In this version the problem does not occur.

I am testing with Cypress 9.6.1.

@kasperg
Copy link
Author

kasperg commented Jan 5, 2023

I have tried to look into this a little deeper myself but I cannot figure out exactly what request(s) in my test cannot be resolved within reasonable time.

With cypress-replay 1.0.16 I have been able to fix the problem by increasing defaultCommandTimeout. That works but perhaps not at scale as it will make other tests fail slower.

Another option would be to introduce a separate configurable timeout which if provided is used specifically for request resolving.

@Sam152
Copy link
Owner

Sam152 commented Jan 6, 2023

This part of the code attempts to wait for all pending requests to complete before writing the fixture file. This prevents requests that are in progress from being skipped by the recording process and potentially going to the origin when replaying.

Short of there being a bug, it's possible that after all the assertions have been made for your test case, you either have a long running request that is not completing or perhaps some kind of overlapping polling that is continually pushing new requests to the collection that are taking additional time to resolve.

I like your proposal, we could perhaps even just nominate a higher default timeout specifically for resolving the request collection.

I'm curious if you were able to diagnose exactly what kind of requests were causing this timeout and what timeout ended up working?

@kasperg
Copy link
Author

kasperg commented Jan 9, 2023

I have not been able to diagnose what requests were causing the timeout.

My approach at the moment has been to log requests as they are intercepted and after a response has been returned. Without further modification the number of intercepted requests is higher than the number of resolved requests.

When I bumped the defaultCommandTimeout from 10 to 60 seconds all requests were resolved and fixture generation worked. 60 is just a somewhat arbitrary but higher value. I do not know what the right value would be in my case.

All tests pass as expected before using cypress-replay and increasing the timeout.

I am fine with with either a configurable or higher default timeout for this and I am willing to help out with implementation as well if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants