Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Nov 6, 2024
1 parent 0d01767 commit f84a2c9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
32 changes: 25 additions & 7 deletions lib/handler/cache-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ class CacheHandler extends DecoratorHandler {
this.#handler = handler
}

onConnect (abort) {
if (this.#writeStream) {
this.#writeStream.destroy()
this.#writeStream = undefined
}

if (typeof this.#handler.onConnect === 'function') {
this.#handler.onConnect(abort)
}
}

/**
* @see {DispatchHandlers.onHeaders}
*
Expand Down Expand Up @@ -136,13 +147,20 @@ class CacheHandler extends DecoratorHandler {
})

if (this.#writeStream) {
this.#writeStream.on('drain', resume)
this.#writeStream.on('error', () => {
// TODO (fix): Make error somehow observable?
this.#writeStream = undefined
// TODO (fix): Should we resume even if was paused downstream?
resume()
})
const stream = this.#writeStream
this.#writeStream
.on('drain', resume)
.on('error', () => {
// TODO (fix): Make error somehow observable?
})
.on('close', () => {
if (this.#writeStream === stream) {
this.#writeStream = undefined
}

// TODO (fix): Should we resume even if was paused downstream?
resume()
})
}
}

Expand Down
8 changes: 8 additions & 0 deletions lib/handler/cache-revalidation-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ class CacheRevalidationHandler extends DecoratorHandler {
this.#handler = handler
}

onConnect (abort) {
this.#successful = false

if (typeof this.#handler.onConnect === 'function') {
this.#handler.onConnect(abort)
}
}

/**
* @see {DispatchHandlers.onHeaders}
*
Expand Down

0 comments on commit f84a2c9

Please sign in to comment.