Skip to content

Commit 7222fce

Browse files
committed
Extend supported Node.js from <=9 to <=14
1 parent 4814647 commit 7222fce

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ node_js:
66
- 7
77
- 8
88
- 9
9+
- 11
10+
- 12
11+
- 13
12+
- 13
13+
- 14
914
script:
1015
- npm run lint
1116
- npm run test

lib/cors-anywhere.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,11 @@ exports.createServer = function createServer(options) {
413413
// This could happen when a protocol error occurs when an error occurs
414414
// after the headers have been received (and forwarded). Do not write
415415
// the headers because it would generate an error.
416+
// Prior to Node 13.x, the stream would have ended.
417+
// As of Node 13.x, we must explicitly close it.
418+
if (res.writableEnded === false) {
419+
res.end();
420+
}
416421
return;
417422
}
418423

test/test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,15 @@ describe('Proxy errors', function() {
385385
});
386386

387387
it('Content-Length mismatch', function(done) {
388+
var errorMessage = 'Error: Parse Error: Invalid character in Content-Length';
389+
// <13.0.0: https://github.com/nodejs/node/commit/ba565a37349e81c9d2402b0c8ef05ab39dca8968
390+
if (parseInt(process.versions.node, 10) < 13) {
391+
errorMessage = 'Error: Parse Error';
392+
}
388393
request(cors_anywhere)
389394
.get('/' + bad_http_server_url)
390395
.expect('Access-Control-Allow-Origin', '*')
391-
.expect(404, 'Not found because of proxy error: Error: Parse Error', done);
396+
.expect(404, 'Not found because of proxy error: ' + errorMessage, done);
392397
});
393398

394399
it('Invalid HTTP status code', function(done) {

0 commit comments

Comments
 (0)