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

feat(ext/http): Implement request.signal for Deno.serve #23425

Merged
merged 3 commits into from Apr 24, 2024

Conversation

mmastrac
Copy link
Member

@mmastrac mmastrac commented Apr 17, 2024

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.

@mmastrac mmastrac changed the title [WIP] Implement request.signal for Deno.serve feat(ext/http): Implement request.signal for Deno.serve [WIP] Apr 17, 2024
return async function (req) {
const abortController = new AbortController();
Copy link
Member

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?

Copy link
Member Author

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.

Comment on lines 287 to 293
if (!this.#completed) {
this.#completed = Promise.withResolvers<void>();
}
return this.#completed.promise;
Copy link
Member

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!

Comment on lines 541 to 554
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;
Copy link
Member

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

Comment on lines -33 to -36
/// Stream provided trailers.
// TODO(mmastrac): We are threading trailers through the response system to eventually support Grpc.
#[allow(unused)]
Trailers(HeaderMap),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this one?

Copy link
Member Author

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 🙃

@mmastrac mmastrac changed the title feat(ext/http): Implement request.signal for Deno.serve [WIP] feat(ext/http): Implement request.signal for Deno.serve Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants