-
Notifications
You must be signed in to change notification settings - Fork 659
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
Allow configurable timeouts for page and XHR requests #2940
Comments
I was able to reproduce the issue and prepared an example without calling any external sites' API. Test page: <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="jsonDisplay"></div>
<script>
const url = 'http://127.0.0.1:8081?test=1';
const jsonDisplay = document.querySelector('#jsonDisplay');
fetch(url).then(function(response) {
response.text().then(function(text) {
jsonDisplay.innerHTML = text;
});
});
</script>
</body>
</html> Test code import { Selector } from 'testcafe';
const DestinationRequest = require('../../../../../../node_modules/testcafe-hammerhead/lib/request-pipeline/destination-request');
const http = require('http');
fixture `fixture`;
test('test', async t => {
// DestinationRequest.TIMEOUT = 60000;
const server = http.createServer((req, res) => {
res.writeHead(200, {
'Content-Type': 'text/json',
'Access-Control-Allow-Origin': '*',
});
setTimeout(() => {
res.write('hello');
res.end();
}, 40000);
});
server.listen(8081);
await t.navigateTo(`http://127.0.0.1:8080/index.html`);
await t.expect(Selector('#jsonDisplay').visible).ok();
await t.expect(Selector('#jsonDisplay').textContent).contains('hello');
// DestinationRequest.TIMEOUT = 25000;
}); You are right; the issue occurs when the server doesn't respond for a long period. This constant is defined in the testcafe core module |
I've discussed the issue with my colleagues and we decided that would be useful to have public options to set the timeout, so I'll mark the issue as proposal. |
@AlexKamaev Thanks for the quick turnaround. Really appreciated. |
One more request (TestCafe Studio): https://www.devexpress.com/Support/Center/Question/Details/T726255/test-failures-failed-to-complete-a-request-within-the-timeout-period |
Any update on this at all? Very keen to see this implemented. |
@cericoli we haven't decided about the interface that can be used to modify such intrinsic values. We don't want to overwhelm regular users with excessive configuration details. Maybe we can introduce a section in the configuration file structure. But this problem still needs o lot of planning and development, so I can't give you any estimates. |
Team, are we going to have resolutions on that? |
Currently, we do not have any news regarding this. |
In this case, any workaround is highly appreciated. |
@zhkostadinov, |
The link which is posted leads to |
Hello, Yes, you can change these timeouts: _defineProperty(DestinationRequest, "TIMEOUT", 25 * 1000);
_defineProperty(DestinationRequest, "XHR_TIMEOUT", 2 * 60 * 1000);
The assertion timeout increase cannot fix the issue with the request. Could you please share your simple project (or a public URL), so that we can reproduce the issue? We will examine it and check for a suitable solution. |
Hello @Farfurix , thanks for the reply. Unfortunately, I'm not able to share that information, because it is for internal usage, and doesn't have a public part. |
It changed: const defaultTimeout = require('testcafe-hammerhead/lib/request-pipeline/destination-request/default-request-timeout');
defaultTimeout.page = 600000;
// defaultTimeout.ajax = 1200000; |
Hello @znar , We've added an API that allows you to configure request timeouts: https://github.com/DevExpress/testcafe/blob/master/docs/articles/documentation/reference/command-line-interface.md#--ajax-request-timeout-ms. |
Any updates on this on latest release 1.5.3 ?? @aleks-pro , I am having the same issue. How to increase timeouts please? TypeError: Cannot set property 'ajax' of undefined Code is nt working defaultTimeout.ajax = 10 * 60 * 1000; |
Hello, Please use the following API to configure your timeouts: |
Are you requesting a feature or reporting a bug?
Bug
What is the current behavior?
Any XHR that takes longer than 20 seconds will make tests depending on parsing the response fail
What is the expected behavior?
Either the page load ltimeout or another timeout should be available to make testcafe not fail when XHR take longer than 20 seconds
How would you reproduce the current behavior (if this is a bug)?
Run the below test which loads twp page that retrieve a simple JSON from a remote service using XHR. The first page XHR response returns in less than 1 sec. The second page XHR response returns in 25 seconds. The first succeeds but the second fails because testcafe gives up on XHR that take over 20 seconds.
Using the following command the test ends with the below error:
Note that the command sets to 1 minute all the available timeouts. Optionally and for the record, see below the html of this page in case you want to host it yourself. Change the mocky-delay param to have a page to render in 1ms and another in 25s (If you host it you will need to either have the XHR service in the same sub-domain or provide CORS support for the remote service):
Provide the test code and the tested page URL (if applicable)
See above. Note that this is an issue that will result in tests suddenly not passing after a release just because the responses from the database are slower for instance. The test failure in that case becomes a distraction, a false positive.It would be ideal to have a configurable timeout for XHR responses or use the same page load timeout to fix the currently hardcoded 20 seconds landmark.
Specify your
The text was updated successfully, but these errors were encountered: