11// Flags: --expose-internals
22import { mustSucceed } from '../../../common/index.mjs' ;
3+ import { mustNotCall } from '../../../common/index.mjs' ;
34import assert from 'node:assert' ;
45import { existsSync } from 'node:fs' ;
56import { fileURLToPath } from 'node:url' ;
@@ -110,6 +111,10 @@ async function runTest() {
110111 res . json ( { status : 'ok' } ) ;
111112 } ) ;
112113
114+ app . get ( / ^ \/ r e g e x \/ ( \d + ) $ / , ( req , res ) => {
115+ res . json ( { userId : req . params [ 0 ] } ) ;
116+ } ) ;
117+
113118 // Track connections for forceful close
114119 const connections = new Set ( ) ;
115120 const server = await new Promise ( ( resolve ) => {
@@ -148,6 +153,8 @@ async function runTest() {
148153 } ) ;
149154 } ) ;
150155
156+ process . once ( 'uncaughtException' , mustNotCall ( 'regex Express routes must not throw in http.server.response.finish' ) ) ;
157+
151158 // Make HTTP requests to trigger routes
152159 console . log ( 'Making HTTP requests...' ) ;
153160
@@ -166,6 +173,11 @@ async function runTest() {
166173 assert . strictEqual ( response . status , 200 ) ;
167174 console . log ( 'Requested /health' ) ;
168175
176+ // Request to regex route - should not set http.route or throw
177+ response = await fetch ( `http://127.0.0.1:${ serverPort } /regex/789` ) ;
178+ assert . strictEqual ( response . status , 200 ) ;
179+ console . log ( 'Requested /regex/789' ) ;
180+
169181 // Wait for all metrics to be reported
170182 await metricsPromise ;
171183
0 commit comments