MCPcopy Index your code
hub / github.com/nodejs/node / testHttp2Error

Function testHttp2Error

test/parallel/test-inspector-network-http2.js:286–317  ·  view source on GitHub ↗
(secure = false)

Source from the content-addressed store, hash-verified

284}
285
286async function testHttp2Error(secure = false) {
287 const port = (secure ? http2SecureServer : http2Server).address().port;
288 const origin = (secure ? 'https' : 'http') + `://localhost:${port}`;
289 const errorUrl = `${origin}/trigger-error`;
290
291 const requestWillBeSent = once(session, 'Network.requestWillBeSent');
292 session.on('Network.responseReceived', common.mustNotCall());
293 session.on('Network.loadingFinished', common.mustNotCall());
294 const loadingFailed = once(session, 'Network.loadingFailed');
295
296 const client = http2.connect(origin, {
297 rejectUnauthorized: false,
298 });
299 const request = client.request(requestErrorHeaders);
300
301 request.on('close', common.mustCall(() => {
302 assert.strictEqual(request.rstCode, http2.constants.NGHTTP2_STREAM_CLOSED);
303 client.close();
304 }));
305 request.on('error', common.expectsError({
306 code: 'ERR_HTTP2_STREAM_ERROR',
307 name: 'Error',
308 message: 'Stream closed with error code NGHTTP2_STREAM_CLOSED'
309 }));
310 request.end();
311
312 const [ requestEvent ] = await requestWillBeSent;
313 verifyRequestWillBeSent(requestEvent, errorUrl);
314
315 const [ failed ] = await loadingFailed;
316 verifyLoadingFailed(failed);
317}
318
319const testNetworkInspection = async () => {
320 await testHttp2();

Callers 1

testNetworkInspectionFunction · 0.85

Calls 9

onceFunction · 0.70
verifyRequestWillBeSentFunction · 0.70
verifyLoadingFailedFunction · 0.70
addressMethod · 0.65
connectMethod · 0.65
requestMethod · 0.65
closeMethod · 0.65
onMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…