MCPcopy Create free account
hub / github.com/nodejs/node / patch

Function patch

benchmark/diagnostics_channel/http.js:37–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35function none() {}
36
37function patch() {
38 const als = new AsyncLocalStorage();
39 const times = [];
40
41 const { emit } = http.Server.prototype;
42 function wrappedEmit(...args) {
43 const [name, req, res] = args;
44 if (name === 'request') {
45 als.enterWith({
46 url: req.url,
47 start: process.hrtime.bigint(),
48 });
49
50 res.on('finish', () => {
51 times.push({
52 ...als.getStore(),
53 statusCode: res.statusCode,
54 end: process.hrtime.bigint(),
55 });
56 });
57 }
58 return emit.apply(this, args);
59 }
60 http.Server.prototype.emit = wrappedEmit;
61
62 return () => {
63 http.Server.prototype.emit = emit;
64 };
65}
66
67function diagnostics_channel() {
68 const als = new AsyncLocalStorage();

Callers 14

mock_runMethod · 0.85
setUpMethod · 0.85
testWithFakeContextMethod · 0.85
testHeavySequenceMethod · 0.85
testNumFuzzerMethod · 0.85
with_fake_rdbMethod · 0.85
test_basicMethod · 0.85
test_fast_processMethod · 0.85
test_logMethod · 0.85

Calls

no outgoing calls

Tested by 14

mock_runMethod · 0.68
setUpMethod · 0.68
testWithFakeContextMethod · 0.68
testHeavySequenceMethod · 0.68
testNumFuzzerMethod · 0.68
with_fake_rdbMethod · 0.68
test_basicMethod · 0.68
test_fast_processMethod · 0.68
test_logMethod · 0.68