-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
feat(ext/http): Implement request.signal for Deno.serve #23425
Conversation
return async function (req) { | ||
const abortController = new AbortController(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure we want to create one unconditionally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a great way to do this conditionally right now -- we'd have to refactor Request
a bit for that. For now, impact seems small (not zero).
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
ext/http/00_serve.ts
Outdated
if (!this.#completed) { | ||
this.#completed = Promise.withResolvers<void>(); | ||
} | ||
return this.#completed.promise; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great that it's lazy!
ext/http/00_serve.ts
Outdated
let options: { | ||
port?: number; | ||
hostname?: string; | ||
signal?: AbortSignal; | ||
reusePort?: boolean; | ||
key?: string; | ||
cert?: string; | ||
onError?: (error: unknown) => Response | Promise<Response>; | ||
onListen?: (params: { hostname: string; port: number }) => void; | ||
handler?: ( | ||
request: Request, | ||
info: ServeHandlerInfo, | ||
) => Response | Promise<Response>; | ||
} | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are changing this file to be TS consider factoring this out to be an interface outside this function. Gonna be a lot easier to read and parse
/// Stream provided trailers. | ||
// TODO(mmastrac): We are threading trailers through the response system to eventually support Grpc. | ||
#[allow(unused)] | ||
Trailers(HeaderMap), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was unused -- we ended up doing trailers a different way 🙃
When the response has been successfully send, we abort the
Request.signal
property to indicate that all resources associated with this transaction may be torn down.