Skip to content

Commit 01e771a

Browse files
authored
fix: preserve request statusText and update h2 dispatch tests (#4830)
1 parent 66b08b1 commit 01e771a

File tree

3 files changed

+19
-34
lines changed

3 files changed

+19
-34
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ jobs:
269269
fail-fast: false
270270
max-parallel: 0
271271
matrix:
272+
# Node.js 22 is intentionally excluded here: --shared-builtin-undici/undici-path
273+
# embedding is only validated for supported/current majors.
272274
node-version: ['24', '25']
273275
runs-on: ['ubuntu-latest']
274276
with:

lib/api/api-request.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class RequestHandler extends AsyncResource {
8787
this.context = context
8888
}
8989

90-
onResponseStart (controller, statusCode, headers, _statusMessage) {
90+
onResponseStart (controller, statusCode, headers, statusText) {
9191
const { callback, opaque, context, responseHeaders, highWaterMark } = this
9292

9393
const rawHeaders = controller?.rawHeaders
@@ -126,6 +126,7 @@ class RequestHandler extends AsyncResource {
126126
try {
127127
this.runInAsyncScope(callback, null, null, {
128128
statusCode,
129+
statusText,
129130
headers: responseHeaderData,
130131
trailers: this.trailers,
131132
opaque,

test/http2-dispatcher.js

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -511,19 +511,13 @@ test('Should send http2 PING frames', async t => {
511511
method: 'PUT',
512512
body: 'hello'
513513
}, {
514-
onConnect () {
515-
516-
},
517-
onHeaders () {
518-
return true
519-
},
520-
onData () {
521-
return true
522-
},
523-
onComplete (trailers) {
514+
onRequestStart () {},
515+
onResponseStart () {},
516+
onResponseData () {},
517+
onResponseEnd (_controller, trailers) {
524518
t.strictEqual(trailers['x-trailer'], 'hello')
525519
},
526-
onError (err) {
520+
onResponseError (_controller, err) {
527521
t.ifError(err)
528522
}
529523
})
@@ -588,19 +582,13 @@ test('Should not send http2 PING frames if interval === 0', async t => {
588582
method: 'PUT',
589583
body: 'hello'
590584
}, {
591-
onConnect () {
592-
593-
},
594-
onHeaders () {
595-
return true
596-
},
597-
onData () {
598-
return true
599-
},
600-
onComplete (trailers) {
585+
onRequestStart () {},
586+
onResponseStart () {},
587+
onResponseData () {},
588+
onResponseEnd (_controller, trailers) {
601589
t.strictEqual(trailers['x-trailer'], 'hello')
602590
},
603-
onError (err) {
591+
onResponseError (_controller, err) {
604592
t.ifError(err)
605593
}
606594
})
@@ -666,19 +654,13 @@ test('Should not send http2 PING frames after connection is closed', async t =>
666654
method: 'PUT',
667655
body: 'hello'
668656
}, {
669-
onConnect () {
670-
671-
},
672-
onHeaders () {
673-
return true
674-
},
675-
onData () {
676-
return true
677-
},
678-
onComplete (trailers) {
657+
onRequestStart () {},
658+
onResponseStart () {},
659+
onResponseData () {},
660+
onResponseEnd (_controller, trailers) {
679661
t.strictEqual(trailers['x-trailer'], 'hello')
680662
},
681-
onError (err) {
663+
onResponseError (_controller, err) {
682664
t.ifError(err)
683665
}
684666
})

0 commit comments

Comments
 (0)