-
Notifications
You must be signed in to change notification settings - Fork 673
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
Server responses with status 222 unexpectedly when window.fetch() is called in Chrome #1134
Comments
Hello, Daniele! Please, can you give us some more information about your issue: the Chrome version, your test code and the tested page URL or source code? |
@dzannotti, Also It possible that some chrome extension breaks test running. Please try to run it in the |
Hi Thanks for the support, trying to put together a repro. It's definitely not extensions breaking (as it has the same behaviour in incognito/on ci. The weird thing is the 222 http codes from the testcafe proxy |
Could you please provide us URL to your tested page or create a simple example to reproduce the problem on our side? |
Met the same problem. When I make a request |
Hi,
It's ok because testcafe works via its own proxy, so it sends requests to the proxy ( |
@AlexanderMoskovkin Hi. I only get an unknow response.
|
@Darmody Is it possible to share your application or create a simple example to reproduce the problem on our page? Or maybe you can give us some tips to create the same simple application to reproduce the problem? It's too hard to determine the cause of the problem without a page |
@AlexanderMoskovkin After run testcafe, you can directly call |
It works ok on the simple page on my side. I think the problem is specific to your backend realization. |
@AlexanderMoskovkin Hm.. could you show me the response? Maybe I missed some headers? |
the request too, thank you. @AlexanderMoskovkin |
Above is the infomation about request. It is a cors json API call, and I use rails as backend |
@AlexanderMoskovkin thank you |
does json api call cause the problem? |
Could you please provide the same info (request,response) when you call this on the original page (without testcafe) |
|
Thanks for the info. We'll try to investigate it. If we need some more info we will write you. |
OK! That's cool. |
Hi @Darmody I investigated this problem and I think that it relates with the our CORS emulation. We response with the 222 status code if the CORS conditions are failed. I figured out that our proxy does't send the |
@LavrovArtem Hi. This is my sever-side setting: I don't limit |
@Darmody thanks for information. I've reproduced this problem and I've created an issue: Wrong CORS emulation |
@LavrovArtem cool |
Hi @MarinaRukavitsyna the problem was that I was not configuring CORS correctly when making the request |
I've got the same problem, and in my case, the issue might be that the proxy is not sending the correct cookies in the header. In my TestCafe terminal, I see the following cookies:
However, when the XHR request goes out from the browser, the headers I see are
and the response is
|
I am afraid this information is not sufficient to reproduce. Could you please provide a page or a small example so that we can reproduce it on our side? |
Thanks for the quick response, @miherlosev, much appreciated! 😃 Here's the test code: const appUrl = `http://localhost:${appPort}/watch`;
test.only('should request a download', async (t) => {
await t
.useRole(loggedInUser(appUrl))
.navigateTo(appUrl);
await setupMock(REMOTE_DOWNLOAD_URI, 'POST', { error: null, ok: 1 }, epgPort);
await clickRemoteDownloadButton(t);
}); where const loggedInUser = url => Role(url, async () => {
await setCookie({
name: 'already-seen-banners',
value: 'cookie-wrapper',
domain: 'localhost'
})();
await setCookie({
name: 'SSOCookie',
value: 'loggedIn',
domain: 'localhost'
})();
});
const setCookie = ({ name, value, domain = 'localhost', url = `http://localhost:${appPort}` }) => ClientFunction(() => {
document.cookie = `${name}=${value};domain=${domain};url=${url}`;
}, {
dependencies: { name, value, domain, url }
});
Additionally, the rendered page has a button clicking which generates a POST request to the mocked endpoint, http://localhost:5201/remotedownload/download/3830670 (as noted in my previous comment). I hope this info is adequate for you to take a look at the issue. |
Make sure that |
Yes, this is how it is already:
|
Please, try to update your const setCookie = ({ name, value, domain = 'localhost', path = `http://localhost:${appPort}` }) => ClientFunction(() => {
document.cookie = `${name}=${value};domain=${domain};path=${path}`;
}, {
dependencies: { name, value, domain, path }
}); |
That didn't work, nor did removing the General:
Request headers:
Response headers:
|
I don't have any ideas of how to find the cause of the problem without an example. |
You can run just about any Node app with the example test code that I've given above. You can skip the |
It is likely that the cause of the problem relates to your application specifics.
You can create an example as a separate repository with all required dependencies and share a link with us. |
Sorry, @miherlosev - I've got a bit busy over the last few days. Will post an example app as soon as I can. |
Here's the app: I've kept it very simple:
The test expects the response to be what's stubbed in mountebank, but instead a 222 response comes back from testcafe's proxy. |
At first glance, your mountebank setup has two issues:
I suggest using TestCafe's built-in |
@miherlosev Thanks for this: setting |
I’m trying to do a fetch put request with storage.googleapis.com. However, I get a 222 status code back instead of 200. How do I resolve this without mocking the call instead? |
@alexistaocognite Could you please provide an example on which I can reproduce the problem on my computer? |
First run some test from testcafe, then open up the dev tools console for the window the test is running in. Enter (some sample code from https://gist.github.com/justsml/529d0b1ddc5249095ff4b890aad5e801) Then the response is something weird with things like However, if you run that code in a different window's devTools console, you would get a different response. In my code, I'm using a Google APIs url instead of the sample one above. |
@alexistaocognite We need a complete example. It should contain the test code and the tested web page (public web site, web app example or something else). We need to be able to easily download and run this code and reproduce the problem on our side. |
@miherlosev Okay, it's here #3535 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests. For TestCafe API, usage and configuration inquiries, we recommend asking them on StackOverflow. |
Are you requesting a feature or reporting a bug?
Reporting a possible bug
What is the current behavior?
Some requests in chrome seem to return 222 from the proxy and no json content, however the same tests work correctly in firefox and safari. There don't seem to be major differences investigating curl differences which sort of leads me to believe it's a chrome fetch related issue
What is the expected behavior?
That a page with a third party xhr request works consistently in browser.
How would you reproduce the current behavior (if this is a bug)?
Do not have a repro currently, it seems that xhr requests in chrome are not currently working
Specify your
The text was updated successfully, but these errors were encountered: