Skip to content

Commit 71560fe

Browse files
mcollinaclaude
andauthored
test: fix flaky http2-dispatcher test (#4633)
Co-authored-by: Claude <[email protected]>
1 parent f69e47b commit 71560fe

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

test/http2-dispatcher.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,25 @@ test('Dispatcher#Connect', async t => {
145145
})
146146
after(() => forward.close())
147147

148-
const response = await forward.request({
149-
path: '/',
150-
method: 'POST',
151-
body: stream,
152-
headers: {
153-
'x-my-header': headers['x-my-header']
154-
}
155-
})
148+
try {
149+
const response = await forward.request({
150+
path: '/',
151+
method: 'POST',
152+
body: stream,
153+
headers: {
154+
'x-my-header': headers['x-my-header']
155+
}
156+
})
156157

157-
stream.respond({ ':status': 200, 'x-my-header': response.headers['x-my-header'] })
158-
response.body.pipe(stream)
158+
stream.respond({ ':status': 200, 'x-my-header': response.headers['x-my-header'] })
159+
pipeline(response.body, stream, (err) => {
160+
if (err) {
161+
stream.destroy(err)
162+
}
163+
})
164+
} catch (err) {
165+
stream.destroy(err)
166+
}
159167
})
160168

161169
server.on('stream', (stream, headers) => {

0 commit comments

Comments
 (0)