Closed bartekfj closed 4 years ago
Hi, could you post the test code you are running? Feel free to blur our request urls if needed.
Hey, I'm sorry for not providing enough information. Request is generated by button click, so test is simulating user behavior. Here is simplified version of my test.
describe('create request', () => {
before(() => {
cy.login()
})
after(() => {
cy.logout()
})
it('create request', () => {
cy.visit(Cypress.env('url'))
cy.contains('h1', 'Create request')
cy.get('button').contains('launch').click()
cy.get('#default').should('be.visible').click()
cy.get('.page-form')
cy.get('#input').clear().type('request name')
.should('have.value', 'request name')
cy.get('#option1').type('test')
cy.get('#option2').click()
// request fails on this step after two minutes
cy.get('couple of selectors here').contains('Create').click()
cy.get('.page-content', {timeout: 200000})
.should('contain', 'Created successfully!')
})
})
Also i was able to achieve similar behavior with this example application with sleep set to 150 seconds on backend and "responseTimeout" set to 5 minutes in Cypress.
# chunk of modified run.py file from example application
@app.route('/api/random')
def random_number():
sleep(150)
response = {
'randomNumber': randint(1, 100)
}
return jsonify(response)
Request will fail every time right after 2 minutes.
describe('experimental test', () => {
it('timeout test', () => {
cy.visit('http://127.0.0.1:8080')
})
})
@jennifer-shehane does Cypress intercept somehow http requests coming from visited webpage? Is there any close after timeout or retry mechanism? If so can you point module where it might happen?
@jennifer-shehane could it be possible that the default timeout that we can find in here might be the reason. If so, is there a way in cypress to override that? From what I understood cypress does craete a server to somehow proxy requests, right ?
Some update from my side.
Node http server by design has timeout set to 2 minutes.
Because Cypress proxies all traffic through this server, requests are failing right after 2 minutes.
I was able to fix this problem for modified example application case by changing timeout in Cypress/resources/app/packages/server/lib/server.js
file (Cypress CDN version).
// chunk of Cypress server.js file
_this._server = http.createServer(app);
_this._server.setTimeout(0); // added line
allowDestroy(_this._server);
Problem still exist for webapp from my first comment that I'm working with. Why there is a second request sent right after 2 minutes which is visible in Cypress log is still not determined.
Edit:
It seems solution for webapp is quite similar (it uses https by default).
In this case problem is caused by default node https server timeout which can be fixed by changing timeout in Cypress/resources/app/packages/https-proxy/lib/server.js
file (Cypress CDN version).
// chunk of Cypress server.js file
_this._sniServer = https.createServer({});
_this._sniServer.setTimeout(0); // added line
allowDestroy(_this._sniServer);
Now I wonder if this is something that Cypress should allow by default?
Thanks for looking into this @bartekfj, we'll have to discuss exactly how this should be implemented for use within Cypress, but I believe this should be configurable as we've seen many issues of socket timeouts that may be negated by increasing this beyond the 2 minutes default.
We will be closing this issue due to inactivity since no one has commented in a year and half. Please comment if there is new information to provide concerning the original issue and we can reopen.
I can try to see if I can reproduce this, afaik we do not have code explicitly preventing this but it could still be an issue in 2020.
I cannot post my code unfortunately here is the behavior I have: I upload an excel with around 15k rows inside and doing some computations on it.
the request goes to the web api (request is pending)
after two minutes, I can see that my web api is receiving a second call, the same as the first one. This second call is not sent by my frontend, nothing appears in the dev tools network tab and the code calling my web api is not triggered
when I manually stop the test I can see the second call to my api appearing in the cypress logs
Hope it can help, I am using Windows 10 - Cypress 4.11 - Node 10.18.1
Solution to my issue : Split the excel in multiple chunks taking less than 2 minutes to be uploaded
Closing this issue since it has been fixed: #6426
Is this a Feature or Bug?
Bug
Current behavior:
I'm sending request to server that takes couple of minutes to get response. Every single time right after two minutes request fails in Cypress. Then Cypress sends the same request right after that which causes unwanted behavior in webapp. In Cypress console log I can see two requests but in Chrome dev tools there is only one. "responseTimeout" is set to 300000 (5 minutes).
There is no issue when request is sent manually with the same version of Chrome and OS.
Desired behavior:
Cypress should wait for response according to "responseTimeout" that is longer than two minutes.
Steps to reproduce:
Send request that takes more than two minutes to get response.
Versions
Cypress version: 3.0.1 Browser: Chrome 67 OS: Ubuntu Linux 16.04 LTS