Skip to content

Commit 00f8422

Browse files
committed
BREAKING CHANGE(server): get rid of conditions of Node version
1 parent f5498c9 commit 00f8422

File tree

5 files changed

+47
-98
lines changed

5 files changed

+47
-98
lines changed

azure-pipelines.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ jobs:
5050
node_version: ^12.0.0
5151
webpack_version: latest
5252
node-10:
53-
node_version: ^10.13.0
53+
node_version: ^10.20.1
5454
webpack_version: latest
5555
node-10-canary:
56-
node_version: ^10.13.0
56+
node_version: ^10.20.1
5757
webpack_version: next
5858
steps:
5959
- task: NodeTool@0
@@ -103,10 +103,10 @@ jobs:
103103
node_version: ^12.0.0
104104
webpack_version: latest
105105
node-10:
106-
node_version: ^10.13.0
106+
node_version: ^10.20.1
107107
webpack_version: latest
108108
node-10-canary:
109-
node_version: ^10.13.0
109+
node_version: ^10.20.1
110110
webpack_version: next
111111
steps:
112112
- task: NodeTool@0
@@ -156,10 +156,10 @@ jobs:
156156
node_version: ^12.0.0
157157
webpack_version: latest
158158
node-10:
159-
node_version: ^10.13.0
159+
node_version: ^10.20.1
160160
webpack_version: latest
161161
node-10-canary:
162-
node_version: ^10.13.0
162+
node_version: ^10.20.1
163163
webpack_version: next
164164
steps:
165165
- script: 'git config --global core.autocrlf input'

lib/Server.js

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77
*/
88
const fs = require('fs');
99
const path = require('path');
10-
const tls = require('tls');
1110
const url = require('url');
1211
const http = require('http');
1312
const https = require('https');
1413
const ip = require('ip');
15-
const semver = require('semver');
1614
const killable = require('killable');
1715
const chokidar = require('chokidar');
1816
const express = require('express');
@@ -35,15 +33,6 @@ const routes = require('./utils/routes');
3533
const getSocketServerImplementation = require('./utils/getSocketServerImplementation');
3634
const schema = require('./options.json');
3735

38-
// Workaround for node ^8.6.0, ^9.0.0
39-
// DEFAULT_ECDH_CURVE is default to prime256v1 in these version
40-
// breaking connection when certificate is not signed with prime256v1
41-
// change it to auto allows OpenSSL to select the curve automatically
42-
// See https://github.com/nodejs/node/issues/16196 for more information
43-
if (semver.satisfies(process.version, '8.6.0 - 9')) {
44-
tls.DEFAULT_ECDH_CURVE = 'auto';
45-
}
46-
4736
if (!process.env.WEBPACK_DEV_SERVER) {
4837
process.env.WEBPACK_DEV_SERVER = true;
4938
}
@@ -656,35 +645,14 @@ class Server {
656645

657646
createServer() {
658647
if (this.options.https) {
659-
// Only prevent HTTP/2 if http2 is explicitly set to false
660-
const isHttp2 = this.options.http2 !== false;
661-
662-
// `spdy` is effectively unmaintained, and as a consequence of an
663-
// implementation that extensively relies on Node’s non-public APIs, broken
664-
// on Node 10 and above. In those cases, only https will be used for now.
665-
// Once express supports Node's built-in HTTP/2 support, migrating over to
666-
// that should be the best way to go.
667-
// The relevant issues are:
668-
// - https://github.com/nodejs/node/issues/21665
669-
// - https://github.com/webpack/webpack-dev-server/issues/1449
670-
// - https://github.com/expressjs/express/issues/3388
671-
if (semver.gte(process.version, '10.0.0') || !isHttp2) {
672-
if (this.options.http2) {
673-
// the user explicitly requested http2 but is not getting it because
674-
// of the node version.
675-
this.log.warn(
676-
'HTTP/2 is currently unsupported for Node 10.0.0 and above, but will be supported once Express supports it'
677-
);
678-
}
679-
this.listeningApp = https.createServer(this.options.https, this.app);
680-
} else {
681-
// The relevant issues are:
682-
// https://github.com/spdy-http2/node-spdy/issues/350
683-
// https://github.com/webpack/webpack-dev-server/issues/1592
648+
if (this.options.http2) {
649+
// TODO: we need to replace spdy with http2 which is an internal module
684650
this.listeningApp = require('spdy').createServer(
685651
this.options.https,
686652
this.app
687653
);
654+
} else {
655+
this.listeningApp = https.createServer(this.options.https, this.app);
688656
}
689657
} else {
690658
this.listeningApp = http.createServer(this.app);

package-lock.json

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"client"
1212
],
1313
"engines": {
14-
"node": ">= 6.11.5"
14+
"node": ">= 10.20.1"
1515
},
1616
"scripts": {
1717
"lint:prettier": "prettier \"{**/*,*}.{js,json,md,yml,css}\" --list-different",
@@ -57,7 +57,6 @@
5757
"portfinder": "^1.0.25",
5858
"schema-utils": "^2.6.6",
5959
"selfsigned": "^1.10.7",
60-
"semver": "^7.3.2",
6160
"serve-index": "^1.9.1",
6261
"sockjs": "0.3.20",
6362
"sockjs-client": "1.4.0",

test/server/http2-option.test.js

Lines changed: 36 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
22

33
const path = require('path');
4+
const http2 = require('http2');
45
const request = require('supertest');
5-
const semver = require('semver');
66
const testServer = require('../helpers/test-server');
77
const config = require('../fixtures/contentbase-config/webpack.config');
88
const port = require('../ports-map')['http2-option'];
@@ -16,60 +16,47 @@ describe('http2 option', () => {
1616
let server;
1717
let req;
1818

19-
// HTTP/2 will only work with node versions below 10.0.0
20-
// since spdy is broken past that point, and this test will only
21-
// work above Node 8.8.0, since it is the first version where the
22-
// built-in http2 module is exposed without need for a flag
23-
// (https://nodejs.org/en/blog/release/v8.8.0/)
24-
// if someone is testing below this Node version and breaks this,
25-
// their tests will not catch it, but CI will catch it.
26-
if (
27-
semver.gte(process.version, '8.8.0') &&
28-
semver.lt(process.version, '10.0.0')
29-
) {
30-
const http2 = require('http2');
31-
describe('http2 works with https', () => {
32-
beforeAll((done) => {
33-
server = testServer.start(
34-
config,
35-
{
36-
contentBase: contentBasePublic,
37-
https: true,
38-
http2: true,
39-
port,
40-
},
41-
done
42-
);
43-
req = request(server.app);
44-
});
45-
46-
it('confirm http2 client can connect', (done) => {
47-
const client = http2.connect(`https://localhost:${port}`, {
48-
rejectUnauthorized: false,
49-
});
50-
client.on('error', (err) => console.error(err));
19+
describe('http2 works with https', () => {
20+
beforeAll((done) => {
21+
server = testServer.start(
22+
config,
23+
{
24+
contentBase: contentBasePublic,
25+
https: true,
26+
http2: true,
27+
port,
28+
},
29+
done
30+
);
31+
req = request(server.app);
32+
});
5133

52-
const http2Req = client.request({ ':path': '/' });
34+
it('confirm http2 client can connect', (done) => {
35+
const client = http2.connect(`https://localhost:${port}`, {
36+
rejectUnauthorized: false,
37+
});
38+
client.on('error', (err) => console.error(err));
5339

54-
http2Req.on('response', (headers) => {
55-
expect(headers[':status']).toEqual(200);
56-
});
40+
const http2Req = client.request({ ':path': '/' });
5741

58-
http2Req.setEncoding('utf8');
59-
let data = '';
60-
http2Req.on('data', (chunk) => {
61-
data += chunk;
62-
});
63-
http2Req.on('end', () => {
64-
expect(data).toEqual(expect.stringMatching(/Heyo/));
65-
done();
66-
});
67-
http2Req.end();
42+
http2Req.on('response', (headers) => {
43+
expect(headers[':status']).toEqual(200);
6844
});
6945

70-
afterAll(testServer.close);
46+
http2Req.setEncoding('utf8');
47+
let data = '';
48+
http2Req.on('data', (chunk) => {
49+
data += chunk;
50+
});
51+
http2Req.on('end', () => {
52+
expect(data).toEqual(expect.stringMatching(/Heyo/));
53+
done();
54+
});
55+
http2Req.end();
7156
});
72-
}
57+
58+
afterAll(testServer.close);
59+
});
7360

7461
describe('server works with http2 option, but without https option', () => {
7562
beforeAll((done) => {

0 commit comments

Comments
 (0)