Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 551d975

Browse filesBrowse files
mcollinaaddaleax
authored andcommitted
http2: fix flaky test-http2-https-fallback
The test was flaky because it relied on a specific order of asynchronous operation that were fired paralellely. This was true on most platform and conditions, but not all the time. See: #18986 PR-URL: #19093 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent cc90bbd commit 551d975
Copy full SHA for 551d975

File tree

Expand file treeCollapse file tree

1 file changed

+29
-16
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+29
-16
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-http2-https-fallback.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http2-https-fallback.js
+29-16Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function onRequest(request, response) {
3131
}));
3232
}
3333

34-
function onSession(session) {
34+
function onSession(session, next) {
3535
const headers = {
3636
':path': '/',
3737
':method': 'GET',
@@ -54,6 +54,10 @@ function onSession(session) {
5454

5555
session.close();
5656
this.cleanup();
57+
58+
if (typeof next === 'function') {
59+
next();
60+
}
5761
}));
5862
request.end();
5963
}
@@ -126,22 +130,31 @@ function onSession(session) {
126130
connect(
127131
origin,
128132
clientOptions,
129-
common.mustCall(onSession.bind({ cleanup, server }))
133+
common.mustCall(function(session) {
134+
onSession.call({ cleanup, server },
135+
session,
136+
common.mustCall(testNoTls));
137+
})
130138
);
131139

132-
// HTTP/1.1 client
133-
get(Object.assign(parse(origin), clientOptions), common.mustNotCall())
134-
.on('error', common.mustCall(cleanup))
135-
.end();
136-
137-
// Incompatible ALPN TLS client
138-
let text = '';
139-
tls(Object.assign({ port, ALPNProtocols: ['fake'] }, clientOptions))
140-
.setEncoding('utf8')
141-
.on('data', (chunk) => text += chunk)
142-
.on('end', common.mustCall(() => {
143-
ok(/Unknown ALPN Protocol, expected `h2` to be available/.test(text));
144-
cleanup();
145-
}));
140+
function testNoTls() {
141+
// HTTP/1.1 client
142+
get(Object.assign(parse(origin), clientOptions), common.mustNotCall)
143+
.on('error', common.mustCall(cleanup))
144+
.on('error', common.mustCall(testWrongALPN))
145+
.end();
146+
}
147+
148+
function testWrongALPN() {
149+
// Incompatible ALPN TLS client
150+
let text = '';
151+
tls(Object.assign({ port, ALPNProtocols: ['fake'] }, clientOptions))
152+
.setEncoding('utf8')
153+
.on('data', (chunk) => text += chunk)
154+
.on('end', common.mustCall(() => {
155+
ok(/Unknown ALPN Protocol, expected `h2` to be available/.test(text));
156+
cleanup();
157+
}));
158+
}
146159
}));
147160
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.