Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cache #3804

Merged
merged 17 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
WIP
  • Loading branch information
ronag committed Nov 6, 2024
commit b48d306768989c146700065296013903c9fc23b4
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 handler = this
this.#writeStream
.on('drain', resume)
.on('error', function () {
// TODO (fix): Make error somehow observable?
})
.on('close', function () {
if (handler.#writeStream === this) {
handler.#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
Loading