TestCafe - Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client - testing

Started to get Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client in random places using TestCafe.
I have a local node module that is a wrapper on createTestCafe() api. Module is called testcafe-runner and is installed like this "testcafe-runner": "file:local_modules/testcafe-runner".
I started to get the error with the following exception:
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at ServerResponse.setHeader (_http_outgoing.js:485:11)
at RequestPipelineContext.redirect (C:\MyTests\local_modules\testcafe-runner\node_modules\testcafe-hammerhead\lib\request-pipeline\context.js:278:9)
at TestRun.handlePageError (C:\MyTests\local_modules\testcafe-runner\node_modules\testcafe\src\test-run\index.js:287:13)
at SessionController.handlePageError (C:\MyTests\local_modules\testcafe-runner\node_modules\testcafe\src\test-run\session-controller.js:43:36)
at error (C:\MyTests\local_modules\testcafe-runner\node_modules\testcafe-hammerhead\lib\request-pipeline\utils.js:81:48)
at DestinationRequest.<anonymous> (C:\MyTests\local_modules\testcafe-runner\node_modules\testcafe-hammerhead\lib\request-pipeline\utils.js:62:9)
at DestinationRequest.emit (events.js:209:13)
at DestinationRequest.EventEmitter.emit (domain.js:476:20)
at DestinationRequest._onError (C:\MyTests\local_modules\testcafe-runner\node_modules\testcafe-hammerhead\lib\request-pipeline\destination-request\index.js:171:17)
at ClientRequest.<anonymous> (C:\MyTests\local_modules\testcafe-runner\node_modules\testcafe-hammerhead\lib\request-pipeline\destination-request\index.js:93:40) {
domainThrown: true
}
npm ERR! code ELIFECYCLE
npm ERR! errno 7
All test javascript files are located in C:\MyTests folder.
Version of testcafe 1.8.4 installed on both local_module and project

I am getting the exact error.
testcafe - 1.8.4
OS - Mac Catalina
browser - chrome 81
Node - 12.16.3
This is happening while clicking on a logout button.
There is 302 redirection happening and ultimately user is redirected back to login page.
The test cafe browser url is shown as at failure http://localhost:1337/03WvIUCEQ/about:error

Related

Unable to read local json file on live Vercel site using getServerSideProps?

Im having issues deploying a project on Vercel. On my local machine the app is working as expected. Yet on the live site I'm running into a 500 internal error message. The project uses MongoDB and Next-Auth. In the .env.local file I created a env variable for NEXTAUTH_URL = localhost/3000. In Vercel, I created a NEXTAUTH_URL = "project-site" env variable for production. At the moment there isn't any MongoDB env variable set up. The error message in the function logs reads out
[GET] /_next/data/A8gtiRNZmw7m2Db85BoGe/suggestions.json
15:40:24:81
2022-05-26T19:40:26.691Z e41995a4-dac5-4f4e-aa1c-fbbcd2787d91 ERROR [Error: ENOENT: no such file or directory, open '/var/task/public/data/data.json'] {
errno: -2,
syscall: 'open',
path: '/var/task/public/data/data.json',
page: '/suggestions'
}
RequestId: e41995a4-dac5-4f4e-aa1c-fbbcd2787d91 Error: Runtime exited with error: exit status 1
Runtime.ExitError
Any tips are greatly appreciated.

Hyperledger Fabric error: "TLS: bad certificate server" when installing chaincode

I'm just starting learning HLF, and I have an error while following tutorial from the docs: link
I downloaded fabric-samples using this command (replaced bit.ly link with the destination):
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh | bash -s -- 2.2.2 1.4.9
I run logspout in one terminal and try to execute peer lifecycle chaincode install basic.tar.gz in another one, and this is the result i get
Error: failed to retrieve endorser client for install: endorser client
failed to connect to localhost:7051: failed to create new connection:
context deadline exceeded
Log presented by Logspout:
peer0.org1.example.com|2022-03-15 13:03:24.452 UTC [core.comm]
ServerHandshake -> ERRO 04a Server TLS handshake failed in 2.650245ms
with error remote error: tls: bad certificate server=PeerServer
remoteaddress=172.22.0.1:61126
I set the envs in terminal as instructed in the docs, and I checked that CORE_PEER_TLS_ROOTCERT_FILE variable points to an existing file. The content of the file is the same as on the container.
What I tried to do:
download fabric-samples again and redo all the setup with copy-pasting the commands directly from docs
Do you have any suggestions where I can look for an issue?
I resolved the problem, I was using peer version 2.2.1 from previous experiments, it probably collided with FABRIC_CFG_PATH

Azure Data Factory Automated publishing for continuous integration and delivery

I’m following the new CICD guide for ADF https://learn.microsoft.com/en-us/azure/data-factory/continuous-integration-deployment-improvements
Looks like I'm missing files credential and managedVirtualNetwork. Do I need to set up authentication with the npm module and Azure packages?
Getting these errors:
LocalFileClientService: Unable to list files for: credential, error: Error: ENOENT: no such file or directory, scandir '/home/vsts/work/1/s/credential'
…
LocalFileClientService: Unable to list files for: managedVirtualNetwork, error: Error: ENOENT: no such file or directory, scandir '/home/vsts/work/1/s/managedVirtualNetwork'
…
ERROR === CmdApiApp: Failed to run resource validation. Error: {"stack":"TypeError: Cannot read property 'concept' of undefined\n at Function.<anonymous> (/home/vsts/work/1/s/downloads/main.js:1271:27040)\n at /home/vsts/work/1/s/downloads/main.js:16:2243\n at Object.next (/home/vsts/work/1/s/downloads/main.js:16:2348)\n at o (/home/vsts/work/1/s/downloads/main.js:16:1087)","message":"Cannot read property 'concept' of undefined"}
…
error code ELIFECYCLE
error errno 1
error # build: `node node_modules/#microsoft/azure-data-factory-utilities/lib/index "validate" "/home/vsts/work/1/s" "subscriptions/xxxxxxx/resourceGroups/xxxxxxx/providers/Microsoft.DataFactory/factories/xxxxxxxx”
error Exit status 1
error Failed at the # build script.
error This is probably not a problem with npm. There is likely additional logging output above.
##[error]Error: Npm failed with return code: 1
The missing credential and managedVirtualNetwork folders are not an issue. I am able to validate and export the ARM template even without having those folders.
I was able to reproduce the error with an incorrect ADF Resource ID. The leading / before 'subscriptions' is missing. Changing the Resource ID to /subscriptions/xxxxxxx/resourceGroups/xxxxxxx/providers/Microsoft.DataFactory/factories/xxxxxxxx should work.

How do I prevent node from sending errors to the console?

Working on a React project.
I start up my environment using npm start. I then start my testing infrastructure using npm test in a different terminal. While my tests are running, errors are generated and printed in the terminal that my environment is running in.
npm start
Compiled successfully!
You can now view v2 in the browser.
Local: http://localhost:3000
Note that the development build is not optimized.
To create a production build, use yarn build.
Open another terminal and run npm test
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 2.415s
Ran all test suites.
Yet, some UI errors that the tests generate appear in the terminal for my local environment
Compiled successfully!
You can now view v2 in the browser.
Local: http://localhost:3000
Note that the development build is not optimized.
To create a production build, use yarn build.
[HPM] Error occurred while trying to proxy request /directory from localhost:3000 to <TARGET> (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
[HPM] Error occurred while trying to proxy request /directory from localhost:3000 to <TARGET> (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
[HPM] Error occurred while trying to proxy request /directory from localhost:3000 to <TARGET> (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
[HPM] Error occurred while trying to proxy request /directory from localhost:3000 to <TARGET> (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
[HPM] Error occurred while trying to proxy request /directory from localhost:3000 to <TARGET> (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
How do I prevent errors - and anything else for that matter - from being printed out to the terminal where I started my dev environment?
looking at the output of your npm test, it seems like you are using jest, which has a support for configuring setup files
A list of paths to modules that run some code to configure or set up the testing framework before each test file in the suite is executed.
you can utilize it by pointing to a file, where you can mock the implmentation for console.
add to jest.config.js the following
module.exports = {
setupFilesAfterEnv: ['./jest.setup.js'],
};
then in jest.setup.js file
global.beforeAll(() => {
// disable console.error for clarity
console.error = jest.fn().mockImplementation(() => {});
});
note that it will achieve what you desire only if the module that prints to the console during the testing is using console.error(). otherwise, you might need to mock other functions, such as console.info(), console.log(), console.debug()

CypressError: `cy.visit()` failed trying to load: https://dev-eccc.env.xxxx.com/ via Gitlab CI job

I have setup a Gitlab ci/cd job to execute all cypress integration tests. I found that all tests are getting fail due to home URL is getting failed to load by cy.visit().
On my local machine it is working fine.
below is the complete Error trace:
CypressError: `cy.visit()` failed trying to load:
https://dev-eccc.env.ihsmarkit.com/
We attempted to make an http request to this URL but the request failed without a response.
We received this error at the network level:
> Error: getaddrinfo ENOTFOUND dev-eccc.env.ihsmarkit.com
Common situations why this would fail:
- you don't have internet access
- you forgot to run / boot your web server
- your web server isn't accessible
- you have weird network configuration settings on your computer
Because this error occurred during a `before all` hook we are skipping the remaining tests in the current suite: `Facility Register`
at http://localhost:45271/__cypress/runner/cypress_runner.js:156433:23
at visitFailedByErr (http://localhost:45271/__cypress/runner/cypress_runner.js:155794:12)
at http://localhost:45271/__cypress/runner/cypress_runner.js:156432:11
at tryCatcher (http://localhost:45271/__cypress/runner/cypress_runner.js:10130:23)
at Promise._settlePromiseFromHandler (http://localhost:45271/__cypress/runner/cypress_runner.js:8065:31)
at Promise._settlePromise (http://localhost:45271/__cypress/runner/cypress_runner.js:8122:18)
at Promise._settlePromise0 (http://localhost:45271/__cypress/runner/cypress_runner.js:8167:10)
at Promise._settlePromises (http://localhost:45271/__cypress/runner/cypress_runner.js:8243:18)
at _drainQueueStep (http://localhost:45271/__cypress/runner/cypress_runner.js:4837:12)
at _drainQueue (http://localhost:45271/__cypress/runner/cypress_runner.js:4830:9)
at Async.../../node_modules/bluebird/js/release/async.js.Async._drainQueues
(http://localhost:45271/__cypress/runner/cypress_runner.js:4846:5)
at Async.drainQueues (http://localhost:45271/__cypress/runner/cypress_runner.js:4716:14)
From Your Spec Code:
at Object.homepage_test (http://localhost:45271/__cypress/tests?p=cypress/integration/eccc-
app-ui-cypress/API/register_api.ts:71:8)
at Context.eval (http://localhost:45271/__cypress/tests?p=cypress/integration/eccc-app-ui-
cypress/API/register_api.ts:13:25)
From Node.js Internals:
Error: getaddrinfo ENOTFOUND dev-eccc.env.ihsmarkit.com
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:26)