Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions lib/interceptor/dump.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class DumpHandler extends DecoratorHandler {
super(handler)

this.#maxSize = maxSize ?? this.#maxSize
// this.#handler = handler
}

#abort (reason) {
Expand All @@ -46,7 +45,7 @@ class DumpHandler extends DecoratorHandler {
}

if (this.aborted === true) {
return true
return super.onResponseStart(controller, statusCode, headers, statusMessage)
}

return super.onResponseStart(controller, statusCode, headers, statusMessage)
Expand All @@ -68,24 +67,22 @@ class DumpHandler extends DecoratorHandler {

if (this.#size >= this.#maxSize) {
this.#dumped = true

if (this.aborted === true) {
super.onResponseError(controller, this.reason)
} else {
super.onResponseEnd(controller, {})
}
}

// Don't pass data to handler - we're dumping/discarding it
// Return true to indicate we've consumed the data
return true
}

onResponseEnd (controller, trailers) {
if (this.#dumped) {
if (this.#controller.aborted === true) {
super.onResponseError(controller, this.reason)
return
}

if (this.#controller.aborted === true) {
super.onResponseError(controller, this.reason)
if (this.#dumped) {
// Response was dumped, end with empty trailers
super.onResponseEnd(controller, {})
return
}

Expand Down
Loading