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

Cucumber task will time out when iterating over a large list of items #1102

Closed
3 tasks done
hammzj opened this issue Oct 9, 2023 · 14 comments
Closed
3 tasks done

Cucumber task will time out when iterating over a large list of items #1102

hammzj opened this issue Oct 9, 2023 · 14 comments

Comments

@hammzj
Copy link

hammzj commented Oct 9, 2023

Current behavior

I have a test which validates a website that displays a configuration page of feature flags for a given organization. These feature flags are displayed as a list of divs that include a title, description, and value. In one example, there are 90 items I need to validate in a single step, using the backend contents and checking that they're accurate on the webpage.

Whenever I try to validate these through cypress open, the testrunner freezes for a slight bit, will complete the validation, but fail due to an error with a Cypress task not being completed in 60 seconds.

Testrunner output
Screenshot 2023-10-09 at 11 07 30 AM
Test error
Screenshot 2023-10-09 at 11 07 41 AM

Desired behavior

Add ability to set the task timeout of the task either using a Cypress configuration option or environment variable.

Secondly, allow debugging to be enabled for the Cypress Cucumber internal tasks.

Test code to reproduce

Note: this test case can cause problems with Chrome and crash the browser occasionally! As well, the length of the list of items may need to changed based on your computer's internal memory. I'm able to recreate this without crashing on a MacOS with Ventura 13.6 and 16GB of RAM at 70 iterations, but Chrome crashes above that.

I have a test project with a branch here that can be forked: https://github.com/hammzj/cypress-testing/tree/dev/cypress-issue-task-timeout

Versions

  • Cypress version: 12.12.0
  • Preprocessor version: 18.0.2 (also on 18.0.6)
  • Node version: 18.16.0

Checklist

@hammzj
Copy link
Author

hammzj commented Oct 9, 2023

I do see that adding a small cy.wait in the for each block seems to avoid the testrunner freezing as frequently and causing the task to timeout, so that is definitely a way to avoid this issue without code changes. However, this shows that Cypress has issues with many sequential commands that do not have a gap between them.

@badeball
Copy link
Owner

badeball commented Oct 9, 2023

The task seen failing isn't run unless messages or pretty reporting is turned on, which I can't see that it is in your repository. Can you make the necessary changes and confirm that you see the error using the code you're providing me?

@hammzj
Copy link
Author

hammzj commented Oct 9, 2023

It had been happening earlier, but I'll see about making those changes. This might be intermittent due to it relying on hardware architecture as well.

However, based on my proposed solution, is it possible to allow configuring the timeout of Cucumber tasks from an environment variable instead of it being hard set at 60 seconds?

@badeball
Copy link
Owner

badeball commented Oct 9, 2023

You can configure task timeouts using taskTimeout. However, I'm not going to make any changes to the library until it is evident that it actually is a task timeout happening as opposed to Cypress misreporting where time is spent (this has come up before).

@hammzj
Copy link
Author

hammzj commented Oct 10, 2023

Is taskTimeout configurable via a tag pattern, like in the test-configuration.md? I could utilize that, though I am finding a short 100 ms wait is helping mitigate these problems.

I am still working on a more consistent reproducible example as well.

@badeball
Copy link
Owner

Is taskTimeout configurable via a tag pattern, like in the test-configuration.md? I could utilize that, though I am finding a short 100 ms wait is helping mitigate these problems.

No, I don’t think so. The tag pattern is merely a bridge to test configuration as described here: https://docs.cypress.io/guides/references/configuration#Test-Configuration

This library doesn’t contain any knowledge of valid tags and will simply propagate “anything”. If Cypress doesn’t recognise a property, I suppose it will silently ignored it, albeit unrecognised tags aren’t tested so I’m not entirely sure.

@hammzj
Copy link
Author

hammzj commented Oct 10, 2023

Right, I've understood that but not so much as what the preprocessor offers in terms of abstracting tags to the Cypress configuration.

In this case, would it be possible that a new tag is added for @taskTimeout(X) in lines with how @defaultCommandTimeout(X) and others operate? That would work best in fixing this issue until cypress-io/cypress#25326 is resolved. I am going to make a note there as well on the slowdown.

@badeball
Copy link
Owner

In this case, would it be possible that a new tag is added for @taskTimeout(X) in lines with how @defaultCommandTimeout(X) and others operate?

No. As I tried to say, this library doesn’t concern itself with what tags you write, it merely translates them. You can write your above-mentioned tag but it’s just not going to do anything, because it’s not a recognised test-specific property by Cypress.

@hammzj
Copy link
Author

hammzj commented Oct 10, 2023

It is possible to set the taskTimeout with a tag 😄 :

Feature image
Testrunner Screenshot 2023-10-10 at 2 52 56 PM

The property for taskTimeout is included in Cypress.TestConfigOverrides which is returned within the function tagToCypressOptions. Only thing that will need updated is the markdown doc for "test-configuration".

@badeball
Copy link
Owner

Only thing that will need updated is the markdown doc for "test-configuration".

No, That page is only intended to be a mirror of Cypress' documentation. If it's wrong, then Cypress' documentation is wrong. If you have found that there's additional, undocumented configuration options available, then you need to direct your attention appropriately.

@hammzj
Copy link
Author

hammzj commented Oct 10, 2023

I would have been happy to make that change in the markdown document as much as I'm happy to address it with Cypress. There's always room for clarity, however, and there's definitely more encouraging ways to address developers raising attention to issues without negative reinforcement.

@hammzj
Copy link
Author

hammzj commented Oct 10, 2023

@hammzj
Copy link
Author

hammzj commented Oct 15, 2023

Documentation has been updated on Cypress' side with the PR listed above!

Edit: I meant to add that I could open a PR here to update the docs with that tag since the documentation has been updated on Cypress' side. Not to be persistent, but it is a good callout in case others need to toggle that option per scenario. Let me know if that works!

@badeball
Copy link
Owner

I managed to reproduce the issue eventually. Furthermore, I managed to reproduce it without using the preprocessor, as seen here. In other words, it has nothing to with the preprocessor. The error also appears to disappear with Cypress v13.0.0. Considering this resolved, thus closing.

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

No branches or pull requests

2 participants