Testcafe: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client

Created on 28 Apr 2020  路  30Comments  路  Source: DevExpress/testcafe

What is your Test Scenario?

When I run simple test

import { Selector } from 'testcafe';

fixture `Page tests`
    .page `https://localhost:44300` 
    .httpAuth({
        username: process.env['USERNAME'],
        password: process.env['USERPWD'],
        domain: process.env['USERDOMAIN'],
        workstation: process.env['USERDOMAIN']
    });

test('Element exists', async t => {
    await t
        .resizeWindow(1920, 1080)
        .expect(Selector('#elementId').exists).ok();
});

on chrome, chrome:headless it passes every time. When I try run it on IE 11/Windows 10 or Edge 18.18363 / Windows 10 it fails.

What is the Current behavior?

Currently what I get is this exception:

...\node_modules\testcafe-hammerhead\lib\request-pipeline\connection-reset-guard.js:21
  throw err;
  ^

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at ServerResponse.setHeader (_http_outgoing.js:526:11)
    at RequestPipelineContext.redirect (...\node_modules\testcafe-hammerhead\lib\request-pipeline\context.js:278:9)
    at TestRun.handlePageError (...\node_modules\testcafe\src\test-run\index.js:287:13)
    at SessionController.handlePageError (...\node_modules\testcafe\src\test-run\session-controller.js:43:36)
    at error (...\node_modules\testcafe-hammerhead\lib\request-pipeline\utils.js:81:48)
    at DestinationRequest.<anonymous> (...\node_modules\testcafe-hammerhead\lib\request-pipeline\utils.js:62:9)
    at DestinationRequest.emit (events.js:310:20)
s:171:17)
    at ClientRequest.<anonymous> (...\node_modules\testcafe-hammerhead\lib\request-pipeline\destination-request\index.js:93:40) {
  code: 'ERR_HTTP_HEADERS_SENT',
  domainThrown: true
}

What is the Expected behavior?

No exception on IE or Edge.

What is聽your web application and聽your TestCafe聽test code?

The test are run on sample ASP.NET Core application with Windows auth enabled.


Your complete configuration file (if any):

{
    "browsers": [
        "ie",
        "edge",
        "chrome:headless"
    ],
    "pageLoadTimeout": 10000,
    "screenshots": {
        "takeOnFails": true,
        "fullPage": true
    }
}

Your Environment details:

  • testcafe version: 1.8.4
  • node.js version: 12.16.2
  • command-line arguments: testcafe ie tests.js
  • browser name and version: IE 11, Edge 18
  • platform and version: Windows 10
Need research

All 30 comments

We were reported the same issue earlier. However, we still cannot reproduce it on our side. Could you please create a simple example where this behavior is shown? Alternatively, you can debug this issue on your side in the playground task of our testcafe-hammerhead proxy server.

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.

We started to see this error after we updated from version 1.2.1 to 1.8.4. It happens fairly frequently, every fifth run or so.

Can't pinpoint what the issue is since re-running the exact same tests under the exact same conditions doesn't produce a consistent result. The tests are runned on ubuntu-18.04.

Hello @ganhammar ,

Can you provide us with a test and a simple project example (or a public URL of your site) with which we can reproduce the issue?

NOTE: Our policy prevents us from accessing internal resources without prior written approval from a site owner. If you want us to further research the problem directly on your side, please ask the website owner to send us (mailto:[email protected]) a written confirmation. It must permit DevExpress personnel to remotely access the website and its internal resources for research/testing/and debugging purposes.

@aleks-pro Unfortunately it's no not at all consistent, it happens at random tests at random points. Most of the time it doesn't happen at all, as mentioned, it's roughly a fifth of all runs where it occurs after the update. I can't reproduce it locally, only on our build server.

We are running the tests in our ci pipelines against an environment which we create for the tests and tare down afterwards.

What we've done is to re-run the tests if the last exit code is 7 up to five times. In most cases one re-run is enough, in some extremely rare cases I've seen two but never more than that.

@ganhammar

Hello,

We cannot reproduce this issue without the requested information. Please feel free to open a new issue if you can share a minimal project with us. We will examine it and check for a suitable solution.

@Farfurix sure, I understand, just wanted you to be aware that there is more people who is having the issue. And, since it's completely random, I won't be able to reproduce it in a sample. It fails at random tests at random points, rerunning the tests without changing anything helps in 99,9% of the case, rerunning twice 100%.

What I see from my test runs the error appears when:

  • I use .debug() in my scripts and wait for few minutes
  • Wrong selector is used and testcafe waits some time to find elements

Seems in both cases it is connected with longer delay when testcafe is trying to search for selector or sits in debug break. Hope this helps a bit :)

@krzysiek-b

Unfortunately, this information does clarify the cause of the issue. We still need an example to reproduce the behavior locally.

Have you tried leaving this sample wait for a while on the debug call on a sample ASP.NET Core (3.1) application?

import` { Selector } from 'testcafe';

fixture `Page tests`
    .page `https://localhost:44300` 
    .httpAuth({
        username: process.env['USERNAME'],
        password: process.env['USERPWD'],
        domain: process.env['USERDOMAIN'],
        workstation: process.env['USERDOMAIN']
    });

test('Element exists', async t => {
    await t
        .resizeWindow(1920, 1080)
                .debug()
        .expect(Selector('#elementId').exists).ok();
});

There is a chance that this issue is fixed in 1.8.5-alpha.3. We can't be sure because we can't consistently reproduce it on our side. Could you please update and check if the error persists?

@alexey-lin Unfortunately the mentioned version does not help.

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at ServerResponse.setHeader (_http_outgoing.js:526:11)
    at RequestPipelineContext.redirect (...\e2e\node_modules\testcafe\node_modules\testcafe-hammerhead\lib\request-pipeline\context.js:281:9)
    at TestRun.handlePageError (...\e2e\node_modules\testcafe\src\test-run\index.js:287:13)
    at SessionController.handlePageError (...\e2e\node_modules\testcafe\src\test-run\session-controller.js:43:36)
    at error (...\e2e\node_modules\testcafe\node_modules\testcafe-hammerhead\lib\request-pipeline\utils.js:81:48)
    at DestinationRequest.<anonymous> (...\e2e\node_modules\testcafe\node_modules\testcafe-hammerhead\lib\request-pipeline\utils.js:62:9)
    at DestinationRequest.emit (events.js:310:20)
    at DestinationRequest.EventEmitter.emit (domain.js:482:12)
    at DestinationRequest._onError (...\e2e\node_modules\testcafe\node_modules\testcafe-hammerhead\lib\request-pipeline\destination-request\index.js:171:17)
    at ClientRequest.<anonymous> (...\e2e\node_modules\testcafe\node_modules\testcafe-hammerhead\lib\request-pipeline\destination-request\index.js:93:40) {
  code: 'ERR_HTTP_HEADERS_SENT',
  domainThrown: true
}

@krzysiek-b
We made a little mistake. The 1.8.5-alpha.3 version doesn't have the fix. We'll update this thread when we release a version with the fix.

The fix is published in 1.8.6-alpha.1.

@LavrovArtem I can't find a commit in the 1.8.6-alpha.1 related to a fix for this issue. Would you mind linking to it in this thread?

Thank you!

@adewinter The fix is included in the following PR in the testcafe-hammerhead repository: https://github.com/DevExpress/testcafe-hammerhead/pull/2315. The hammerhead version was updated in 1.8.6-alpha.1.

Perhaps obvious, but I spend too much time fiddling with it.

I had to update both the global version and the package.json version.

$ npm install testcafe@alpha
$ npm install -g testcafe@alpha

or simply:

$ npm install -g testcafe@alpha --save-dev

I've run my tests and it did not break. Thank you!

Thank you for your feedback. I'm happy that your tests are stable now. Considering this as a duplicate of DevExpress/testcafe-hammerhead#2317.

Hey guys.

I am still getting this error with testcafe 1.9.4, just wondering if there is anyone else, please leave a reaction or comment.

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at ServerResponse.setHeader (_http_outgoing.js:470:11)
    at RequestPipelineContext.redirect (.../node_modules/testcafe-hammerhead/lib/request-pipeline/context.js:285:9)
    at TestRun.handlePageError (.../node_modules/testcafe/src/test-run/index.js:301:13)
    at SessionController.handlePageError (.../node_modules/testcafe/src/test-run/session-controller.js:44:36)
    at error (.../node_modules/testcafe-hammerhead/lib/request-pipeline/utils.js:114:48)
    at DestinationRequest.req.on.err (.../node_modules/testcafe-hammerhead/lib/request-pipeline/utils.js:84:9)
    at DestinationRequest.emit (events.js:182:13)
    at DestinationRequest.EventEmitter.emit (domain.js:441:20)
    at DestinationRequest._onError (.../node_modules/testcafe-hammerhead/lib/request-pipeline/destination-request/index.js:201:17)
    at ClientRequest.req.on.err (.../node_modules/testcafe-hammerhead/lib/request-pipeline/destination-request/index.js:105:40)
child_process.js:660
    throw err;
    ^

Throws randomly on Github Actions using https://github.com/DevExpress/testcafe-action.

@mjaneczek

Hello,

Could you please open a new bug report with a reproducible example?

@mjaneczek, @Farfurix, hi, guys.

I also have this issue using testcafe v1.9.3
When I launch a fixture with 2 or more tests it crashes randomly after a button click. However, when I launch the crashed test with .only it runs perfectly.

I started to look at the stack trace and it looks like if I remove

if (!ctx.isDestResReadableEnded) {
        const rawHeadersStr = err.rawPacket ? err.rawPacket.asciiSlice().split(HTTP_BODY_SEPARATOR)[0].split('\n').splice(1).join('\n') : '';
        const headerSize = rawHeadersStr.length;
        error(ctx, (0, _mxessages.getText)(_messages.MESSAGE.destConnectionTerminated, {
          url: ctx.dest.url,
          message: _messages.MESSAGE.nodeError[err.code] || err.toString(),
          headerSize: headerSize,
          recommendedMaxHeaderSize: getRecommendedMaxHeaderSize(headerSize),
          invalidChars: (0, _httpHeaderParser.getFormattedInvalidCharacters)(rawHeadersStr)
        }));
      }

from testcafe-hammerhead\lib\request-pipeline\utils.js:114:48 the tests don't fail and just pass without any problem.
Is there a way to log to the terminal from that place so I could understand more details on which requests are actually failing?

Update: It does run nicely on our pipelines (where we launch all fixtures) with --concurrency 3 so it does when I try to launch with concurrency locally.

Hi @sheenm

Thank you for this investigation. Try adding the console.dir statement as follows:

req.on('error', err => {
    console.dir(err);
    console.dir(ctx);

    if (!ctx.isDestResReadableEnded) {}
}

and share the test execution log with us.

@miherlosev, sure. Here is the error:

{ Error: read ECONNRESET
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:111:27) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }

For the context - I had to remove business information (URLs, cookies, paths), as I don't have a permission to do so and I think this is not much relevant for the situation:

RequestPipelineContext {
    serverInfo: {
      hostname: 'host-ip',
      port: 53364,
      crossDomainPort: 53365,
      protocol: 'http:',
      domain: 'http://host-ip:53364'
    },
    req: IncomingMessage {
      _readableState: ReadableState {
        objectMode: false,
        highWaterMark: 16384,
        buffer: [BufferList],
        length: 0,
        pipes: [],
        flowing: true,
        ended: true,
        endEmitted: true,
        reading: false,
        constructed: true,
        sync: true,
        needReadable: false,
        emittedReadable: false,
        readableListening: false,
        resumeScheduled: false,
        errorEmitted: false,
        emitClose: true,
        autoDestroy: false,
        destroyed: true,
        errored: null,
        closed: false,
        closeEmitted: false,
        defaultEncoding: 'utf8',
        awaitDrainWriters: null,
        multiAwaitDrain: false,
        readingMore: true,
        decoder: null,
        encoding: null,
        [Symbol(kPaused)]: false
      },
      _events: [Object: null prototype] {
        end: [Array],
        error: [Function (anonymous)]
      },
      _eventsCount: 2,
      _maxListeners: undefined,
      socket: Socket {
        connecting: false,
        _hadError: false,
        _parent: null,
        _host: null,
        _readableState: [ReadableState],
        _events: [Object: null prototype],
        _eventsCount: 8,
        _maxListeners: undefined,
        _writableState: [WritableState],
        allowHalfOpen: true,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: [Server],
        _server: [Server],
        parser: null,
        on: [Function: socketListenerWrap],
        addListener: [Function: socketListenerWrap],
        prependListener: [Function: socketListenerWrap],
        setEncoding: [Function: socketSetEncoding],
        _paused: false,
        _httpMessage: null,
        timeout: 5000,
        [Symbol(async_id_symbol)]: 21971,
        [Symbol(kHandle)]: null,
        [Symbol(kSetNoDelay)]: false,
        [Symbol(lastWriteQueueSize)]: 0,
        [Symbol(timeout)]: [Timeout],
        [Symbol(kBuffer)]: null,
        [Symbol(kBufferCb)]: null,
        [Symbol(kBufferGen)]: null,
        [Symbol(kCapture)]: false,
        [Symbol(kBytesRead)]: 97553,
        [Symbol(kBytesWritten)]: 365864,
        [Symbol(RequestTimeout)]: undefined
      },
      httpVersionMajor: 1,
      httpVersionMinor: 1,
      httpVersion: '1.1',
      complete: true,
      headers: {
        host: 'host-ip:53364',
        connection: 'keep-alive',
        'upgrade-insecure-requests': '1',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36',
        accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
        referer: 'http://host-ip:53364/zNCpIovKi*lzuksL5HC/some_url',
        'accept-encoding': 'gzip, deflate',
        'accept-language': 'en-US,en;q=0.9',
        cookie: 'cookie_value',
        'if-none-match': '"02fc983fcaed61:0"',
        'if-modified-since': 'Fri, 30 Oct 2020 20:37:42 GMT'
      },
      rawHeaders: [
        'Host',
        'host-ip:53364',
        'Connection',
        'keep-alive',
        'Upgrade-Insecure-Requests',
        '1',
        'User-Agent',
        'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36',
        'Accept',
        'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
        'Referer',
        'http://host-ip:53364/zNCpIovKi*lzuksL5HC/some_url',
        'Accept-Encoding',
        'gzip, deflate',
        'Accept-Language',
        'en-US,en;q=0.9',
        'Cookie',
        'cookie_value',
        'If-None-Match',
        '"02fc983fcaed61:0"',
        'If-Modified-Since',
        'Fri, 30 Oct 2020 20:37:42 GMT'
      ],
      trailers: {},
      rawTrailers: [],
      aborted: false,
      upgrade: false,
      url: '/zNCpIovKi*lzuksL5HC/some_url',
      method: 'GET',
      statusCode: null,
      statusMessage: null,
      client: Socket {
        connecting: false,
        _hadError: false,
        _parent: null,
        _host: null,
        _readableState: [ReadableState],
        _events: [Object: null prototype],
        _eventsCount: 8,
        _maxListeners: undefined,
        _writableState: [WritableState],
        allowHalfOpen: true,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: [Server],
        _server: [Server],
        parser: null,
        on: [Function: socketListenerWrap],
        addListener: [Function: socketListenerWrap],
        prependListener: [Function: socketListenerWrap],
        setEncoding: [Function: socketSetEncoding],
        _paused: false,
        _httpMessage: null,
        timeout: 5000,
        [Symbol(async_id_symbol)]: 21971,
        [Symbol(kHandle)]: null,
        [Symbol(kSetNoDelay)]: false,
        [Symbol(lastWriteQueueSize)]: 0,
        [Symbol(timeout)]: [Timeout],
        [Symbol(kBuffer)]: null,
        [Symbol(kBufferCb)]: null,
        [Symbol(kBufferGen)]: null,
        [Symbol(kCapture)]: false,
        [Symbol(kBytesRead)]: 97553,
        [Symbol(kBytesWritten)]: 365864,
        [Symbol(RequestTimeout)]: undefined
      },
      _consuming: false,
      _dumped: true,
      [Symbol(kCapture)]: false,
      [Symbol(RequestTimeout)]: undefined
    },
    res: ServerResponse {
      _events: [Object: null prototype] { finish: [Function: bound resOnFinish] },
      _eventsCount: 1,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      destroyed: true,
      _last: false,
      chunkedEncoding: false,
      shouldKeepAlive: true,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: true,
      sendDate: true,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      _contentLength: null,
      _hasBody: false,
      _trailer: '',
      finished: true,
      _headerSent: true,
      _closed: true,
      socket: null,
      _header: 'HTTP/1.1 304 Not Modified\r\n' +
        'cache-control: no-cache\r\n' +
        'accept-ranges: bytes\r\n' +
        'etag: "02fc983fcaed61:0"\r\n' +
        'set-cookie: cookie_value;path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT\r\n' +
        'x-powered-by: ASP.NET\r\n' +
        'x-xss-protection: 1; mode=block\r\n' +
        'x-frame-options: sameorigin\r\n' +
        'x-content-type-options: nosniff\r\n' +
        'strict-transport-security: max-age=300; includeSubDomains\r\n' +
        'x-azure-ref: azure_ref\r\n' +
        'date: Mon, 02 Nov 2020 10:00:24 GMT\r\n' +
        'Connection: keep-alive\r\n' +
        'Keep-Alive: timeout=5\r\n' +
        '\r\n',
      _keepAliveTimeout: 5000,
      _onPendingData: [Function: bound updateOutgoingData],
      _sent100: false,
      _expect_continue: false,
      statusMessage: 'Not Modified',
      statusCode: 304,
      [Symbol(kCapture)]: false,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: null
    },
    session: <ref *1> SessionController {
      _events: [Object: null prototype] {},
      _eventsCount: 0,
      _maxListeners: undefined,
      uploadStorage: UploadStorage { uploadRoots: [Array] },
      id: 'zNCpIovKi',
      cookies: Cookies { _cookieJar: [CookieJar] },
      proxy: null,
      externalProxySettings: null,
      pageLoadCount: 11,
      pendingStateSnapshot: null,
      injectable: { scripts: [Array], styles: [Array], userScripts: [] },
      requestEventListeners: Map(0) {},
      mocks: Map(0) {},
      disablePageCaching: false,
      allowMultipleWindows: true,
      _recordMode: false,
      windowId: 'lzuksL5HC',
      currentTestRun: TestRun {
        captureRejections: false,
        warningLog: [WarningLog],
        opts: [Object: null prototype],
        test: [Test],
        browserConnection: [BrowserConnection],
        phase: 'inTest',
        driverTaskQueue: [],
        testDoneCommandQueued: true,
        activeDialogHandler: null,
        activeIframeSelector: null,
        speed: 1,
        pageLoadTimeout: 3000,
        disablePageReloads: false,
        disablePageCaching: false,
        disableMultipleWindows: false,
        session: [Circular *1],
        consoleMessages: [BrowserConsoleMessages],
        pendingRequest: null,
        pendingPageError: null,
        controller: [TestController],
        ctx: [Object: null prototype] {},
        fixtureCtx: [Object: null prototype] {},
        currentRoleId: '3YH3mLZ',
        usedRoleStates: [Object: null prototype] {},
        errs: [],
        lastDriverStatusId: '20267.889999900945',
        lastDriverStatusResponse: 'test-done-confirmation',
        fileDownloadingHandled: false,
        resolveWaitForFileDownloadingPromise: null,
        addingDriverTasksCount: 0,
        debugging: false,
        debugOnFail: false,
        disableDebugBreakpoints: false,
        debugReporterPluginHost: [ReporterPluginHost],
        browserManipulationQueue: [BrowserManipulationQueue],
        debugLog: [TestRunDebugLog],
        quarantine: null,
        debugLogger: [Object],
        observedCallsites: [ObservedCallsitesStorage],
        requestHooks: [],
        preventEmitActionEvents: false,
        errScreenshotPath: null,
        [Symbol(testRun)]: true
      },
      [Symbol(kCapture)]: false
    },
    reqBody: Buffer(0) [Uint8Array] [],
    dest: {
      url: 'some_url',
      protocol: 'https:',
      host: 'some_hostname',
      hostname: 'some_hostname',
      port: '',
      partAfterHost: '/some/path',
      auth: undefined,
      isIframe: false,
      isForm: false,
      isScript: false,
      isEventSource: false,
      isHtmlImport: false,
      isWebSocket: false,
      charset: undefined,
      reqOrigin: 'https://some_hostname',
      domain: 'https://some_hostname',
      referer: 'some_url'
    },
    destRes: <ref *2> IncomingMessage {
      _readableState: ReadableState {
        objectMode: false,
        highWaterMark: 16384,
        buffer: [BufferList],
        length: 0,
        pipes: [],
        flowing: null,
        ended: true,
        endEmitted: false,
        reading: false,
        constructed: true,
        sync: true,
        needReadable: false,
        emittedReadable: false,
        readableListening: false,
        resumeScheduled: false,
        errorEmitted: false,
        emitClose: true,
        autoDestroy: false,
        destroyed: false,
        errored: null,
        closed: false,
        closeEmitted: false,
        defaultEncoding: 'utf8',
        awaitDrainWriters: null,
        multiAwaitDrain: false,
        readingMore: true,
        decoder: null,
        encoding: null,
        [Symbol(kPaused)]: null
      },
      _events: [Object: null prototype] { end: [Array] },
      _eventsCount: 1,
      _maxListeners: undefined,
      socket: TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        secureConnecting: false,
        _SNICallback: null,
        servername: 'some_hostname',
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object: null prototype],
        _eventsCount: 9,
        connecting: false,
        _hadError: true,
        _parent: null,
        _host: 'some_hostname',
        _readableState: [ReadableState],
        _maxListeners: undefined,
        _writableState: [WritableState],
        allowHalfOpen: false,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: null,
        _requestCert: true,
        _rejectUnauthorized: false,
        parser: null,
        _httpMessage: [ClientRequest],
        timeout: 25000,
        [Symbol(res)]: [TLSWrap],
        [Symbol(verified)]: true,
        [Symbol(pendingSession)]: null,
        [Symbol(async_id_symbol)]: 26845,
        [Symbol(kHandle)]: null,
        [Symbol(kSetNoDelay)]: false,
        [Symbol(lastWriteQueueSize)]: 0,
        [Symbol(timeout)]: [Timeout],
        [Symbol(kBuffer)]: null,
        [Symbol(kBufferCb)]: null,
        [Symbol(kBufferGen)]: null,
        [Symbol(kCapture)]: false,
        [Symbol(kBytesRead)]: 1657669,
        [Symbol(kBytesWritten)]: 26558,
        [Symbol(connect-options)]: [Object],
        [Symbol(RequestTimeout)]: undefined
      },
      httpVersionMajor: 1,
      httpVersionMinor: 1,
      httpVersion: '1.1',
      complete: true,
      headers: {
        'cache-control': 'no-cache',
        'accept-ranges': 'bytes',
        etag: '"02fc983fcaed61:0"',
        'set-cookie': [Array],
        'x-powered-by': 'ASP.NET',
        'x-xss-protection': '1; mode=block',
        'x-frame-options': 'sameorigin',
        'x-content-type-options': 'nosniff',
        'strict-transport-security': 'max-age=300; includeSubDomains',
        'content-security-policy': "default-src 'self' removed_domains",
        'x-azure-ref': 'azure_ref',
        date: 'Mon, 02 Nov 2020 10:00:24 GMT'
      },
      rawHeaders: [
        'Cache-Control',
        'no-cache',
        'Accept-Ranges',
        'bytes',
        'ETag',
        '"02fc983fcaed61:0"',
        'Set-Cookie',
        'another_cookie_value;Path=/;HttpOnly;Secure;Domain=another_domain_value',
        'Set-Cookie',
        'another_cookie_value;Path=/;HttpOnly;SameSite=None;Secure;Domain=another_domain_value',
        'X-Powered-By',
        'ASP.NET',
        'x-xss-protection',
        '1; mode=block',
        'X-Frame-Options',
        'sameorigin',
        'X-Content-Type-Options',
        'nosniff',
        'Strict-Transport-Security',
        'max-age=300; includeSubDomains',
        'Content-Security-Policy',
        "default-src 'self' removed_domains",
        'X-Azure-Ref',
        'azure_ref',
        'Date',
        'Mon, 02 Nov 2020 10:00:24 GMT'
      ],
      trailers: {},
      rawTrailers: [],
      aborted: false,
      upgrade: false,
      url: '',
      method: null,
      statusCode: 304,
      statusMessage: 'Not Modified',
      client: TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        secureConnecting: false,
        _SNICallback: null,
        servername: 'some_hostname',
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object: null prototype],
        _eventsCount: 9,
        connecting: false,
        _hadError: true,
        _parent: null,
        _host: 'some_hostname',
        _readableState: [ReadableState],
        _maxListeners: undefined,
        _writableState: [WritableState],
        allowHalfOpen: false,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: null,
        _requestCert: true,
        _rejectUnauthorized: false,
        parser: null,
        _httpMessage: [ClientRequest],
        timeout: 25000,
        [Symbol(res)]: [TLSWrap],
        [Symbol(verified)]: true,
        [Symbol(pendingSession)]: null,
        [Symbol(async_id_symbol)]: 26845,
        [Symbol(kHandle)]: null,
        [Symbol(kSetNoDelay)]: false,
        [Symbol(lastWriteQueueSize)]: 0,
        [Symbol(timeout)]: [Timeout],
        [Symbol(kBuffer)]: null,
        [Symbol(kBufferCb)]: null,
        [Symbol(kBufferGen)]: null,
        [Symbol(kCapture)]: false,
        [Symbol(kBytesRead)]: 1657669,
        [Symbol(kBytesWritten)]: 26558,
        [Symbol(connect-options)]: [Object],
        [Symbol(RequestTimeout)]: undefined
      },
      _consuming: false,
      _dumped: false,
      req: ClientRequest {
        _events: [Object: null prototype],
        _eventsCount: 5,
        _maxListeners: undefined,
        outputData: [],
        outputSize: 0,
        writable: true,
        destroyed: false,
        _last: true,
        chunkedEncoding: false,
        shouldKeepAlive: true,
        _defaultKeepAlive: true,
        useChunkedEncodingByDefault: false,
        sendDate: false,
        _removedConnection: false,
        _removedContLen: false,
        _removedTE: false,
        _contentLength: null,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        _closed: false,
        socket: [TLSSocket],
        _header: 'GET /some/path HTTP/1.1\r\n' +
          'Host: some_hostname\r\n' +
          'Connection: keep-alive\r\n' +
          'Upgrade-Insecure-Requests: 1\r\n' +
          'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36\r\n' +
          'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9\r\n' +
          'Referer: some_url\r\n' +
          'Accept-Encoding: gzip, deflate\r\n' +
          'Accept-Language: en-US,en;q=0.9\r\n' +
          'Cookie: cookie_value\r\n' +
          'If-None-Match: "02fc983fcaed61:0"\r\n' +
          'If-Modified-Since: Fri, 30 Oct 2020 20:37:42 GMT\r\n' +
          '\r\n',
        _keepAliveTimeout: 0,
        _onPendingData: [Function: noopPendingOutput],
        agent: [Agent],
        socketPath: undefined,
        method: 'GET',
        maxHeaderSize: undefined,
        insecureHTTPParser: undefined,
        path: '/some/path',
        _ended: false,
        res: [Circular *2],
        aborted: false,
        timeoutCb: [Function: emitRequestTimeout],
        upgradeOrConnect: false,
        parser: null,
        maxHeadersCount: null,
        reusedSocket: true,
        host: 'some_hostname',
        protocol: 'https:',
        [Symbol(kCapture)]: false,
        [Symbol(kNeedDrain)]: false,
        [Symbol(corked)]: 0,
        [Symbol(kOutHeaders)]: [Object: null prototype]
      },
      [Symbol(kCapture)]: false,
      [Symbol(RequestTimeout)]: undefined
    },
    isDestResReadableEnded: false,
    destResBody: null,
    isAjax: false,
    isPage: true,
    isHTMLPage: true,
    isHtmlImport: false,
    isWebSocket: false,
    isIframe: false,
    isSpecialPage: false,
    isWebSocketConnectionReset: false,
    contentInfo: {
      charset: null,
      requireProcessing: false,
      isIframeWithImageSrc: false,
      isCSS: false,
      isScript: false,
      isManifest: false,
      encoding: '',
      contentTypeUrlToken: null,
      isFileDownload: false,
      isNotModified: true,
      isRedirect: undefined
    },
    restoringStorages: null,
    requestId: 'buC2Dl8RW',
    requestFilterRules: [],
    onResponseEventData: [],
    reqOpts: RequestOptions {
      url: 'some_url',
      protocol: 'https:',
      hostname: 'some_hostname',
      host: 'some_hostname',
      port: '',
      path: '/some/path',
      method: 'GET',
      credentials: null,
      body: Buffer(0) [Uint8Array] [],
      isAjax: false,
      rawHeaders: [
        'Host',
        'host-ip:53364',
        'Connection',
        'keep-alive',
        'Upgrade-Insecure-Requests',
        '1',
        'User-Agent',
        'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36',
        'Accept',
        'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
        'Referer',
        'http://host-ip:53364/zNCpIovKi*lzuksL5HC/some_url',
        'Accept-Encoding',
        'gzip, deflate',
        'Accept-Language',
        'en-US,en;q=0.9',
        'Cookie',
        'cookie_value',
        'If-None-Match',
        '"02fc983fcaed61:0"',
        'If-Modified-Since',
        'Fri, 30 Oct 2020 20:37:42 GMT'
      ],
      headers: {
        host: 'some_hostname',
        connection: 'keep-alive',
        'upgrade-insecure-requests': '1',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36',
        accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
        referer: 'some_url',
        'accept-encoding': 'gzip, deflate',
        'accept-language': 'en-US,en;q=0.9',
        'if-none-match': '"02fc983fcaed61:0"',
        'if-modified-since': 'Fri, 30 Oct 2020 20:37:42 GMT',
        cookie: 'ai_user=kPb5b|2020-11-02T09:59:40.115Z; ai_session=1IQ1D|1604311180120|1604311219360.775'
      },
      auth: undefined,
      requestId: 'buC2Dl8RW',
      proxy: undefined,
      agent: Agent {
        _events: [Object: null prototype],
        _eventsCount: 2,
        _maxListeners: undefined,
        defaultPort: 443,
        protocol: 'https:',
        options: [Object],
        requests: {},
        sockets: [Object],
        freeSockets: [Object],
        keepAliveMsecs: 1000,
        keepAlive: true,
        maxSockets: Infinity,
        maxFreeSockets: 256,
        scheduling: 'fifo',
        maxTotalSockets: Infinity,
        totalSocketCount: 3,
        maxCachedSessions: 100,
        _sessionCache: [Object],
        [Symbol(kCapture)]: false
      },
      ecdhCurve: 'auto',
      rejectUnauthorized: false
    },
    parsedClientSyncCookie: { outdated: [], actual: [ [Object] ] },
    isFileProtocol: false,
    nonProcessedDestResBody: null,
    goToNextStage: false,
    mock: undefined,
    isSameOriginPolicyFailed: false,
    windowId: 'lzuksL5HC'
  }

Updates:
Our tests has some await testController.eval(() => location.reload(true)) and await testController.navigateTo(route);.
We used reloads previously to get rid of a bug when our tests hanged and there was only a white screen in the browser. Currently this doesn't happen and we removed them from one test and changed "testController.navigateTo(route);" by mouse clicks. Looks like it worked at least for the test.

@mjaneczek do you have reloads in your tests which causes testcafe crash?

Hey @sheenm, thanks for the update! I have checked and I don't have any refreshes in the failing tests but my every test starts with a "navigateTo" method, for example:

test('example', async (t) => {
  await t
    .useRole(UserRole)
    .navigateTo('/example')
    ...
})

So I guess you could be right, I will replace navigateTo with just a simple click and check does it help, will keep you posted. Thanks again for your comment and hard work!

@mjaneczek we have navigate before each test but in a different way:

fixture.beforeEach(async (testController) => {
    await testController.useRole(userRole);
    await testController.navigateTo(route);
  })

can you try this and check if it helps?

@sheenm To be honest, it's really hard to say. I have just created a file with multiple tests with just "nagivateTo" function, ran a few times on Github Actions/Chrome, and it passed fine. BTW, a few days ago I have changed my browser on CI to "firefox:headless" and it looks like it helps but I am not sure yet.

@mjaneczek, for us getting rid of navigateTo and location.reloads in our tests seems to work. It might be that your tests with navigateTo passed because they were too short because I only got this issue when my tests were more than a minute long.

@miherlosev looks like navigateTo inside tests and await testController.eval(() => location.reload(true)) are the reasons why this error occurs. At lesast in our case.

Guys,

Thank you for this information. We are trying to reproduce the issue. We will update this thread once we have any results.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xalvarez picture xalvarez  路  3Comments

marchugon picture marchugon  路  4Comments

chebum picture chebum  路  3Comments

Lukas-Kullmann picture Lukas-Kullmann  路  3Comments

AndreyBelym picture AndreyBelym  路  3Comments