NPM Update / fix

This commit is contained in:
2024-05-17 14:13:06 +02:00
parent b16049ad89
commit b30941716c
38 changed files with 779 additions and 313 deletions

View File

@ -230,9 +230,9 @@ class Request {
onBodySent (chunk) {
if (this[kHandler].onBodySent) {
try {
this[kHandler].onBodySent(chunk)
return this[kHandler].onBodySent(chunk)
} catch (err) {
this.onError(err)
this.abort(err)
}
}
}
@ -244,9 +244,9 @@ class Request {
if (this[kHandler].onRequestSent) {
try {
this[kHandler].onRequestSent()
return this[kHandler].onRequestSent()
} catch (err) {
this.onError(err)
this.abort(err)
}
}
}
@ -271,14 +271,23 @@ class Request {
channels.headers.publish({ request: this, response: { statusCode, headers, statusText } })
}
return this[kHandler].onHeaders(statusCode, headers, resume, statusText)
try {
return this[kHandler].onHeaders(statusCode, headers, resume, statusText)
} catch (err) {
this.abort(err)
}
}
onData (chunk) {
assert(!this.aborted)
assert(!this.completed)
return this[kHandler].onData(chunk)
try {
return this[kHandler].onData(chunk)
} catch (err) {
this.abort(err)
return false
}
}
onUpgrade (statusCode, headers, socket) {
@ -297,7 +306,13 @@ class Request {
if (channels.trailers.hasSubscribers) {
channels.trailers.publish({ request: this, trailers })
}
return this[kHandler].onComplete(trailers)
try {
return this[kHandler].onComplete(trailers)
} catch (err) {
// TODO (fix): This might be a bad idea?
this.onError(err)
}
}
onError (error) {
@ -311,6 +326,7 @@ class Request {
return
}
this.aborted = true
return this[kHandler].onError(error)
}