@@ -162,12 +162,11 @@ t.test("it only counts once if multiple listeners", async () => {
162162 } ) ;
163163
164164 server . on ( "request" , ( req , res ) => {
165- if ( res . headersSent ) {
166- return ;
167- }
165+ // This is a second listener
166+ } ) ;
168167
169- res . setHeader ( "Content-Type ", "text/plain" ) ;
170- res . end ( "OK" ) ;
168+ server . on ( "request ", ( req , res ) => {
169+ // This is a third listener
171170 } ) ;
172171
173172 await new Promise < void > ( ( resolve ) => {
@@ -178,13 +177,15 @@ t.test("it only counts once if multiple listeners", async () => {
178177 method : "GET" ,
179178 headers : {
180179 "user-agent" : "GPTBot" ,
180+ "x-forwarded-for" : "1.2.3.4" ,
181181 } ,
182182 timeoutInMS : 500 ,
183183 } ) ,
184184 fetch ( {
185185 url : new URL ( "http://localhost:3329/test" ) ,
186186 method : "GET" ,
187187 headers : {
188+ "user-agent" : "GPTBot" ,
188189 "x-forwarded-for" : "1.2.3.4" ,
189190 } ,
190191 timeoutInMS : 500 ,
@@ -196,12 +197,12 @@ t.test("it only counts once if multiple listeners", async () => {
196197 t . same ( userAgents , {
197198 breakdown : {
198199 // eslint-disable-next-line camelcase
199- ai_data_scrapers : { total : 1 , blocked : 0 } ,
200+ ai_data_scrapers : { total : 2 , blocked : 0 } ,
200201 } ,
201202 } ) ;
202203 t . same ( ipAddresses , {
203204 breakdown : {
204- "known_threat_actors/public_scanners" : { total : 1 , blocked : 0 } ,
205+ "known_threat_actors/public_scanners" : { total : 2 , blocked : 0 } ,
205206 } ,
206207 } ) ;
207208 server . close ( ) ;
0 commit comments