GeezerVison is showing github.com — test: fix flaky test-http2-client-upload · nodejs/node@2a2fe8a
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-http2-client-upload.js +11-6Lines changed: 11 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -21,24 +21,29 @@ fs.readFile(loc, common.mustCall((err, data) => { |
21 | 21 | fileData = data; |
22 | 22 |
|
23 | 23 | const server = http2.createServer(); |
| 24 | + let client; |
| 25 | + |
| 26 | + const countdown = new Countdown(3, () => { |
| 27 | + server.close(); |
| 28 | + client.close(); |
| 29 | + }); |
24 | 30 |
|
25 | 31 | server.on('stream', common.mustCall((stream) => { |
26 | 32 | let data = Buffer.alloc(0); |
27 | 33 | stream.on('data', (chunk) => data = Buffer.concat([data, chunk])); |
28 | 34 | stream.on('end', common.mustCall(() => { |
29 | 35 | assert.deepStrictEqual(data, fileData); |
30 | 36 | })); |
| 37 | + // Waiting on close avoids spurious ECONNRESET seen in windows CI. |
| 38 | + // Not sure if this is actually a bug; more details at |
| 39 | + // https://github.com/nodejs/node/issues/20750#issuecomment-511015247 |
| 40 | + stream.on('close', () => countdown.dec()); |
31 | 41 | stream.respond(); |
32 | 42 | stream.end(); |
33 | 43 | })); |
34 | 44 |
|
35 | 45 | server.listen(0, common.mustCall(() => { |
36 | | - const client = http2.connect(`http://localhost:${server.address().port}`); |
37 | | - |
38 | | - const countdown = new Countdown(2, () => { |
39 | | - server.close(); |
40 | | - client.close(); |
41 | | - }); |
| 46 | + client = http2.connect(`http://localhost:${server.address().port}`); |
42 | 47 |
|
43 | 48 | const req = client.request({ ':method': 'POST' }); |
44 | 49 | req.on('response', common.mustCall()); |
|