From 2579fb6c0d76b4a28de97e71f72d9cd454590626 Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Sat, 2 May 2020 19:20:08 +0200 Subject: [PATCH] test-memory: fix test by passing --max-http-header-size The test broke because Node lowered the maximum header size to defend against large headers ( CVE-2018-12121 ). In the test, we do actually want to pass large headers, because all processing in CORS Anywhere is based on headers (the request body would just be forwarded to the destination server). The test failed intermittently with ECONNRESET or "socket hang up" because the server (under test) would close the socket upon receiving a request with too large request headers. --- test/test-memory.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/test-memory.js b/test/test-memory.js index 83d6f0c0..081dfc4b 100644 --- a/test/test-memory.js +++ b/test/test-memory.js @@ -33,7 +33,7 @@ describe('memory usage', function() { // with the standard no-op http module. // args.push('use-http-instead-of-cors-anywhere'); cors_anywhere_child = fork(cors_module_path, args, { - execArgv: ['--expose-gc'], + execArgv: ['--expose-gc', '--max-http-header-size=60000'], }); cors_anywhere_child.once('message', function(cors_url) { cors_api_url = cors_url; @@ -83,8 +83,7 @@ describe('memory usage', function() { cors_anywhere_child.send(null); return; } - http.request(request, function(res) { - res.destroy(); + http.request(request, function() { requestAgain(); }).on('error', function(error) { done(error);