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

Function makeServer

test/parallel/test-quic-h3-callback-errors.mjs:28–45  ·  view source on GitHub ↗
(onheadersHandler, extraOpts = {})

Source from the content-addressed store, hash-verified

26const encoder = new TextEncoder();
27
28async function makeServer(onheadersHandler, extraOpts = {}) {
29 const done = Promise.withResolvers();
30 const ep = await listen(mustCall(async (ss) => {
31 ss.onstream = mustCall((stream) => {
32 // The server completes its response before the client's
33 // callback throws, so the server stream always resolves.
34 stream.closed.then(mustCall());
35 });
36 await ss.closed;
37 done.resolve();
38 }), {
39 sni: { '*': { keys: [key], certs: [cert] } },
40 transportParams: { maxIdleTimeout: 1 },
41 onheaders: onheadersHandler,
42 ...extraOpts,
43 });
44 return { ep, done };
45}
46
47// Sync throw in onheaders callback destroys the stream.
48{

Calls 4

listenFunction · 0.70
mustCallFunction · 0.70
thenMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…