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
cy.writeFile timesout but also runs writeFile beyond the timeout. #3350
Comments
Thanks Jennifer, I'm glad you were able to come up with repro steps. |
Hi @jennifer-shehane do you know if this issue was ever fixed or is planned to be fixed? We are facing a lot of random timeouts with cy.writeFile when running tests on Azure build agents. The timeout occurs in the before all or after all hook and the remaining tests all fail. |
Hi, |
@lisophorm I found a workaround for this issue which I thought I would share in case it helps. I stopped using cy.writeFile and instead used fs.writeFileSync. Firstly I added a task in index.js like: const fs = require('fs');
module.exports = (on, config) => {
on('task', {
writeFile({ filename, data }) {
fs.writeFileSync(filename, data);
return null;
}
})
} Then in my before/after all hooks in the cypress tests I now just use the following to write to the files:
This works well and the cypress tests are stable and run very consistently on Azure build agents. Hope this helps whilst we wait for this issue to be fixed. |
Any update on this? |
I tried like this and it worked for me it('writes until timeout', () => {
cy.then( () => cy.writeFile('./fixtures/my-long-file.txt', Cypress._.times(900000, '😈')) );
}) |
This issue is still open, so no work has been done on it. We are welcome to PRs to fix the issue. |
A couple of notes here: To recreate this issue I added an extra zero to @jennifer-shehane 's test to recreate the issue. it('writes until timeout', () => {
cy.writeFile('./fixtures/my-long-file.txt', Cypress._.times(9000000, '😈'))
}) The websocket request the server to write files1 times out after 4000 MS, but the actual fs writeFile operation that is kicked off in the server is never canceled2. This actually seems to lead to some unresponsiveness in the cypress app ui. Fix Proposal:
Footnotes |
Summarizing the plan of action here:
|
The code for this is done in cypress-io/cypress#19015, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior:
The documentation says it is technically possible for
cy.writeFile
to timeout but it shouldn't, however, it did for me today. I know it was thecy.writeFile
that timedout because it is the only cy.Command in myaftereach
hook.The Error Output:
Desired behavior:
I think Cypress should provide a way to override the timeout or fix it so it can't timeout.
I also think Cypress should not stop running the remaining tests when one fails in the
aftereach
hook. That is a harsh punishment for an intermittent failure. In fact that also is a good case for not failing all tests in theaftereach
since one failure does not necessarily mean they all will fail. Perhaps this needs a rethink as well.Steps to reproduce: (app code and test code)
"Issues without reproducible steps will get closed."
-- How am I supposed to give you code to reproduce this? Do I have to write some OS hook to intercept the writeFile command and make it take longer than 4 seconds?Sorry but I don't have the time to work up some sort of repro steps...this requirement on obvious flaws is an impedance to filing a bug. I've reported the bug, if you all want to just close and do nothing then so be it.
Versions
Cypress package version: 3.0.3
Cypress binary version: 3.0.3
OS Name: Microsoft Windows 10 Enterprise
OS Version: 10.0.17763 Build 17763
Browser: Electron 59 (headless)
The text was updated successfully, but these errors were encountered: