testcafe-browser-provider-browserstack icon indicating copy to clipboard operation
testcafe-browser-provider-browserstack copied to clipboard

No response received for a mocked DELETE request

Open tillh opened this issue 4 years ago • 8 comments

What is your Test Scenario?

We are trying to test a use case where a delete request is triggered. We are mocking this request using the requestHooks. The test does not cause any issues when it is executed locally. But when the test is executed against BrowserStack, it fails most of the time.

What is the Current behavior?

The delete request is executed by the test code. This can be seen in the Hammerhead logs as well as in the BrowserStack network logs. In the BrowserStack network logs you can see that the OPTIONS request is mocked, but there is no response for the DELETE request.

BrowserStack network log OPTIONS request
{
    "pageref": "Page 0",
    "startedDateTime": "2021-04-27T17:24:50.356+02:00",
    "request": {
        "method": "OPTIONS",
        "url": "http://192.168.27.250:60063/eHur9nOl9!a!1!localhost%3A3000/http://localhost:8080/activities-service/v1/activities/:bulkDelete",
        "httpVersion": "HTTP/1.1",
        "cookies": [],
        "headers": [
            {
                "name": "Host",
                "value": "192.168.27.250:60063"
            },
            {
                "name": "Proxy-Connection",
                "value": "keep-alive"
            },
            {
                "name": "Accept-Language",
                "value": "en-us"
            },
            {
                "name": "Access-Control-Request-Method",
                "value": "DELETE"
            },
            {
                "name": "Accept-Encoding",
                "value": "gzip, deflate"
            },
            {
                "name": "Accept",
                "value": "*/*"
            },
            {
                "name": "Origin",
                "value": "http://192.168.27.250:60062"
            },
            {
                "name": "Content-Length",
                "value": "0"
            },
            {
                "name": "Access-Control-Request-Headers",
                "value": "access-control-allow-origin,content-type"
            },
            {
                "name": "Connection",
                "value": "keep-alive"
            },
            {
                "name": "User-Agent",
                "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15"
            },
            {
                "name": "Referer",
                "value": "http://192.168.27.250:60062/"
            }
        ],
        "queryString": [],
        "headersSize": 640,
        "bodySize": 0,
        "comment": ""
    },
    "response": {
        "status": 200,
        "statusText": "OK",
        "httpVersion": "HTTP/1.1",
        "cookies": [],
        "headers": [
            {
                "name": "content-type",
                "value": "text/html; charset=utf-8"
            },
            {
                "name": "access-control-allow-origin",
                "value": "http://192.168.27.250:60062"
            },
            {
                "name": "access-control-allow-methods",
                "value": "GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,PATCH"
            },
            {
                "name": "access-control-allow-headers",
                "value": "access-control-allow-origin,content-type"
            },
            {
                "name": "access-control-max-age",
                "value": "1800"
            },
            {
                "name": "allow",
                "value": "GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,PATCH"
            },
            {
                "name": "Date",
                "value": "Tue, 27 Apr 2021 15:24:50 GMT"
            },
            {
                "name": "Connection",
                "value": "keep-alive"
            },
            {
                "name": "Transfer-Encoding",
                "value": "chunked"
            },
            {
                "name": "Proxy-Connection",
                "value": "keep-alive"
            }
        ],
        "content": {
            "size": 0,
            "mimeType": "text/html; charset=utf-8",
            "comment": ""
        },
        "redirectURL": "",
        "headersSize": 469,
        "bodySize": 0,
        "comment": ""
    },
    "cache": {},
    "timings": {
        "comment": "",
        "send": 0,
        "dns": -1,
        "wait": 57,
        "ssl": -1,
        "connect": 1,
        "receive": 0,
        "blocked": -1
    },
    "comment": "",
    "time": 60
}
BrowserStack network log DELETE request
{
    "pageref": "Page 0",
    "startedDateTime": "2021-04-27T17:24:50.420+02:00",
    "request": {
        "method": "DELETE",
        "url": "http://192.168.27.250:60063/eHur9nOl9!a!1!localhost%3A3000/http://localhost:8080/activities-service/v1/activities/:bulkDelete",
        "httpVersion": "HTTP/1.1",
        "cookies": [],
        "headers": [
            {
                "name": "Host",
                "value": "192.168.27.250:60063"
            },
            {
                "name": "Access-Control-Allow-Origin",
                "value": "*"
            },
            {
                "name": "Accept",
                "value": "application/json; charset=utf-8"
            },
            {
                "name": "Proxy-Connection",
                "value": "keep-alive"
            },
            {
                "name": "Accept-Language",
                "value": "en-us"
            },
            {
                "name": "Accept-Encoding",
                "value": "gzip, deflate"
            },
            {
                "name": "Content-Type",
                "value": "application/json"
            },
            {
                "name": "Origin",
                "value": "http://192.168.27.250:60062"
            },
            {
                "name": "User-Agent",
                "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15"
            },
            {
                "name": "Connection",
                "value": "keep-alive"
            },
            {
                "name": "Referer",
                "value": "http://192.168.27.250:60062/eHur9nOl9/http://localhost:3000/activities"
            },
            {
                "name": "Content-Length",
                "value": "87"
            }
        ],
        "queryString": [],
        "headersSize": 661,
        "bodySize": 87,
        "comment": ""
    },
    "response": {
        "status": 0,
        "statusText": "",
        "httpVersion": "unknown",
        "cookies": [],
        "headers": [],
        "content": {
            "size": 0,
            "mimeType": "",
            "comment": ""
        },
        "redirectURL": "",
        "headersSize": -1,
        "bodySize": -1,
        "comment": "",
        "_error": "No response received"
    },
    "cache": {},
    "timings": {
        "comment": "",
        "send": 0,
        "dns": -1,
        "wait": 0,
        "ssl": -1,
        "connect": -1,
        "receive": 0,
        "blocked": -1
    },
    "comment": "",
    "time": 0
}

This problem occurs mainly in the Safari browser and not with the other tested browsers (Firefox, Edge, Chrome).

The corresponding Hammerhead Logs

Hammerhead logs, local run
hammerhead: proxy Proxy request pm4sxZpT1 OPTIONS / i0xqBeEKM!a!1!localhost % 3 A3000 / http: //localhost:8080/activities-service/v1/activities/:bulkDelete 
    {
        "host": "192.168.27.250:51579",
        "origin": "http://192.168.27.250:51578",
        "access-control-request-method": "DELETE",
        "content-length": "0",
        "access-control-request-headers": "content-type",
        "connection": "keep-alive",
        "accept": "*/*",
        "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15",
        "referer": "http://192.168.27.250:51578/",
        "accept-language": "de-de",
        "accept-encoding": "gzip, deflate"
    } + 5 s
hammerhead: destination Destination request is mocked pm4sxZpT1 200 {
    "access-control-allow-origin": "*",
    "access-control-allow-methods": "*",
    "access-control-allow-headers": "*",
    "allow": "GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,PATCH"
} + 5 s
hammerhead: proxy Proxy resource content info pm4sxZpT1 {
    isAjax,
    encoding: ,
    requireProcessing: false
} + 1 ms
hammerhead: proxy Proxy response pm4sxZpT1 200 {
    "content-type": "text/html; charset=utf-8",
    "access-control-allow-origin": "http://192.168.27.250:51578",
    "access-control-allow-methods": "*",
    "access-control-allow-headers": "*",
    "allow": "GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,PATCH",
    "set-cookie": []
} + 0 ms
hammerhead: proxy Proxy request ahSmYJRXO DELETE / i0xqBeEKM!a!1!localhost % 3 A3000 / http: //localhost:8080/activities-service/v1/activities/:bulkDelete 
    {
        "host": "192.168.27.250:51579",
        "content-type": "application/json",
        "origin": "http://192.168.27.250:51578",
        "accept-encoding": "gzip, deflate",
        "connection": "keep-alive",
        "accept": "application/json; charset=utf-8",
        "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15",
        "referer": "http://192.168.27.250:51578/i0xqBeEKM/http://localhost:3000/activities",
        "content-length": "87",
        "accept-language": "de-de"
    } + 2 ms
hammerhead: destination Destination request is mocked ahSmYJRXO 200 {
    "access-control-allow-origin": "*",
    "access-control-allow-methods": "*",
    "access-control-allow-headers": "*",
    "allow": "GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,PATCH"
} + 3 ms
Hammerhead logs, BrowserStack
hammerhead: proxy Proxy request XAG6NhXUt OPTIONS / PVHD1dFBK!a!1!localhost % 3 A3000 / http: //localhost:8080/activities-service/v1/activities/:bulkDelete 
    {
        "host": "192.168.27.250:51910",
        "origin": "http://192.168.27.250:51909",
        "access-control-request-method": "DELETE",
        "content-length": "0",
        "access-control-request-headers": "content-type",
        "accept": "*/*",
        "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15",
        "referer": "http://192.168.27.250:51909/",
        "accept-language": "en-us",
        "accept-encoding": "gzip, deflate",
        "via": "1.1 browsermobproxy"
    } + 5 s
hammerhead: destination Destination request is mocked XAG6NhXUt 200 {
    "access-control-allow-origin": "*",
    "access-control-allow-methods": "*",
    "access-control-allow-headers": "*",
    "allow": "GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,PATCH"
} + 5 s
hammerhead: proxy Proxy resource content info XAG6NhXUt {
    isAjax,
    encoding: ,
    requireProcessing: false
} + 3 ms
hammerhead: proxy Proxy response XAG6NhXUt 200 {
    "content-type": "text/html; charset=utf-8",
    "access-control-allow-origin": "http://192.168.27.250:51909",
    "access-control-allow-methods": "*",
    "access-control-allow-headers": "*",
    "allow": "GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,PATCH",
    "set-cookie": []
} + 0 ms
hammerhead: proxy Proxy request 5 Q8BpjisH DELETE / PVHD1dFBK!a!1!localhost % 3 A3000 / http: //localhost:8080/activities-service/v1/activities/:bulkDelete 
    {
        "host": "192.168.27.250:51910",
        "content-type": "application/json",
        "origin": "http://192.168.27.250:51909",
        "accept": "application/json; charset=utf-8",
        "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15",
        "referer": "http://192.168.27.250:51909/PVHD1dFBK/http://localhost:3000/activities",
        "content-length": "87",
        "accept-language": "en-us",
        "accept-encoding": "gzip, deflate",
        "via": "1.1 browsermobproxy"
    } + 30 ms

I debugged the Testcafe code during execution and could see that the processing of the DELETE request suddenly stopped in the fetchProxyRequestBody function (request-pipeline/stages.js) without any error message.

What is the Expected behavior?

The DELETE request should return a response.

What is your web application and your TestCafe test code?

Test code
const deleteMock = RequestMock()
    .onRequestTo({ url: /:bulkDelete/, method: 'delete' })
    .respond({}, 200, {
        'access-control-allow-origin': '*',
        'Access-Control-Allow-Methods': 'GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,PATCH',
        'Access-Control-Allow-Headers': 'access-control-allow-origin,content-type',
        'access-control-max-age': '1800',
        allow: 'GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,PATCH',
    });

const deleteOptionsMock = RequestMock()
    .onRequestTo({ url: /:bulkDelete/, method: 'options' })
    .respond('', 200, {
        'access-control-allow-origin': '*',
        'Access-Control-Allow-Methods': 'GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,PATCH',
        'Access-Control-Allow-Headers': 'access-control-allow-origin,content-type',
        'access-control-max-age': '1800',
        allow: 'GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,PATCH',
    });

fixture(`List Activity`)
    .page(
        `${process.env.REACT_APP_ACTIVITIES_SERVICE_URL}:${process.env.REACT_APP_BROWSERSTACK_PORT}/activities`
    )

test.requestHooks(
    deleteOptionsMock,
    activitiesMock,
    deleteMock
)('It deletes 2 activities successfully', async (t) => {
    await t.setTestSpeed(0.5).click(page.checkAll);
    await t.removeRequestHooks(activitiesMock);
    await t.addRequestHooks(mockGetZeroActivitiesSuccess);

    await t.click(page.deleteButton);

    await t.click(page.popUpDeleteButton);

    await t.expect(page.emptyOverlay.exists).ok();
});

Your complete test report:
✖ It deletes 2 activities successfully

   1) AssertionError: expected false to be truthy

      Browser: Safari 14.0.3 / macOS 10.15.6

   (https://automate.browserstack.com/builds/cbc34ca1e00877023dc2987d52a7617b901bc280/sessions/c2c584f43f11f0aa2d2f1b6f76e93c3a35bcbbe5)

         222 |
         223 |    await t.click(page.deleteButton);
         224 |
         225 |    await t.click(page.popUpDeleteButton);
         226 |
       > 227 |    await t.expect(page.emptyOverlay.exists).ok();
         228 |});
         229 |
         230 |test.requestHooks(mockGetActivitiesSuccess, mockBadDeleteRequest)(
         231 |    'It tries to delete 2 activities, none gets deleted',
         232 |    async (t) => {

         at <anonymous>

Steps to Reproduce:

  1. Example project: https://github.com/tillh/testcafe-browserstack 2.yarn install to install dependencies 3.yarn start to start dev server 4.yarn e2e:local to execute tests against a local browser => test will pass always 5.BROWSERSTACK_ACCESS_KEY=YOUR_BROWSERSTACK_KEY BROWSERSTACK_USERNAME=YOUR_BROWSERSTACK_USERNAME yarn e2e:browserstack to execute the test against browserstack. This will fail most of the time. In the network logs you can see that the DELETE request receives no response. status=0 _error=No response received

Your Environment details:

  • testcafe version: 1.14.0
  • node.js version: 14.15.0
  • command-line arguments: testcafe "browserstack:[email protected]:OS X Big Sur" e2e/**/*.e2e-spec.ts -r spec --compiler-options typescript.configPath='./e2e/tsconfig.json'
  • browser name and version: Safari Version 14.0.3
  • platform and version: MacOS 11.2.3 (Local system) / MacOS 10.15.6 (BrowserStack)
  • testcafe-browser-provider-browserstack: 1.13.1

Could this be an issue with the Hammerhead proxy, or is it more related to the connection to Browserstack? (We are already in contact with Browserstack support).

tillh avatar Apr 27 '21 16:04 tillh

Hi @tillh

Could you please share an example that we can run locally?

miherlosev avatar Apr 29 '21 07:04 miherlosev

This issue was automatically closed because there was no response to our request for more information from the original author. Currently, we don't have enough information to take action. Please reach out to us if you find the necessary information and are able to share it. We are also eager to know if you resolved the issue on your own and can share your findings with everyone.

no-response[bot] avatar May 09 '21 08:05 no-response[bot]

Hi @miherlosev, I've updated the issue description with an example project ("Steps to Reproduce").

tillh avatar May 11 '21 16:05 tillh

Thank you for the report. I've reproduced the issue using the example project you shared.

wentwrong avatar May 12 '21 08:05 wentwrong

We are experiencing the same issue with DELETE requests when running our TestCafe tests on BrowserStack. Can you please let me know if there are any updates on fixing this ?

AlexGrisin avatar Jun 03 '21 07:06 AlexGrisin

No updates yet. Once we get any results, we will post them in this thread.

VasilyStrelyaev avatar Jun 04 '21 07:06 VasilyStrelyaev

Another year passed by and we are still having this bug. Are there any updates?

d3ns0n avatar Aug 28 '22 09:08 d3ns0n

Hi @d3ns0n,

We are constantly working on stability, so this issue may be fixed. Please run your tests with the latest TestCafe version (1.20.1) and let me know your results.

miherlosev avatar Aug 30 '22 08:08 miherlosev

This issue has been automatically marked as stale because it has not had any activity for a long period. It will be closed and archived if no further activity occurs. However, we may return to this issue in the future. If it still affects you or you have any additional information regarding it, please leave a comment and we will keep it open.

github-actions[bot] avatar Aug 31 '23 01:08 github-actions[bot]

We're closing this issue after a prolonged period of inactivity. If it still affects you, please add a comment to this issue with up-to-date information. Thank you.

github-actions[bot] avatar Sep 10 '23 01:09 github-actions[bot]