@@ -7,10 +7,8 @@ const { once } = require('node:events');
77const http = require ( 'node:http' ) ;
88const { setImmediate } = require ( 'node:timers/promises' ) ;
99
10- // This test ensures that a keep-alive socket runs its callbacks in the context
11- // of the request currently using it, and in no request context while it is
12- // idle in the agent pool. Other work started by a request must keep its
13- // context after the socket is released.
10+ // Idle socket callbacks must not inherit a completed request's context.
11+ // Active requests and independent asynchronous work must keep theirs.
1412// Refs: https://github.com/nodejs/node/issues/67181
1513
1614const storage = new AsyncLocalStorage ( ) ;
@@ -66,8 +64,6 @@ async function main() {
6664 await setImmediate ( ) ;
6765 assertPooled ( created ) ;
6866
69- // A request that reuses the socket must observe its own context in the
70- // socket timeout.
7167 const secondStore = { requestId : 'second' } ;
7268 await storage . run ( secondStore , common . mustCall ( ( ) => new Promise ( ( resolve ) => {
7369 const req = request ( '/stall' ) ;
@@ -82,12 +78,9 @@ async function main() {
8278 req . on ( 'close' , common . mustCall ( resolve ) ) ;
8379 } ) ) ) ;
8480
85- // Releasing the socket must not alter the context of other work.
8681 releaseBackgroundWork ( ) ;
8782 await backgroundWork ;
8883
89- // An idle socket times out and is closed by the agent outside of the
90- // context of the request that created it.
9184 const thirdStore = { requestId : 'third' } ;
9285 const idle = await storage . run ( thirdStore ,
9386 common . mustCall ( ( ) => completedRequest ( thirdStore ) ) ) ;
0 commit comments