Sometimes log in fails with testcafé

Viewed 490

I'm working on software testing with testcafe, for a month now, I've been facing a problem which is when I run the test and it clicks on the login button, sometimes it passes and sometimes not, which causes the test to fail. it throws an error

Error details: Failed to perform a request to the resource at

"mysite.com" because of an error. The request header's size is 10242 bytes which exceeds the set limit. It causes an internal Node.js error on parsing this header. To fix the problem, you need to add the '--max-http-header-size=...' flag to the 'NODE_OPTIONS' environment variable:

  macOS, Linux (bash, zsh)
  export NODE_OPTIONS='--max-http-header-size=20000'

  Windows (powershell)
  $env:NODE_OPTIONS='--max-http-header-size=20000'

  Windows (cmd)
  set NODE_OPTIONS='--max-http-header-size=20000'

  and then start your tests.

This happens when I run the tests locally and when in Azure Pipelines. I tried with --max-http-header-size=20000 locally and maxHttpHeaderSize in the pipeline, but it's not helping.

Anyone can help?

1 Answers

It seems that there are two errors at play in this case.

First: There is a mistake in the error message. The command for Windows (cmd) should look as follows: set NODE_OPTIONS="--max-http-header-size=20000" (with double quotes).

Second: There is a known issue with header size. If a header is larger than ~65 KB, it is split into multiple packets. Right now, testcafe only takes the last packet into account when calculating the recommended header size. To run tests, you'll need to find an appropriate max header size that is larger than 80 KB as it's the default maxHeaderSize for TestCafe.

Related