Skip to content

Commit

Permalink
chore: throw if aborted prematurely before listen() is invoked
Browse files Browse the repository at this point in the history
  • Loading branch information
Thesephi committed Dec 3, 2024
1 parent c8dea48 commit a05a85b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions http_server_native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ export class Server<AS extends State = Record<string, any>>
const { signal } = this.#options;
const { onListen, ...options } = this.#options;
const { promise, resolve } = createPromiseWithResolvers<Listener>();
if (signal?.aborted) {
// if user somehow aborted before `listen` is invoked, we throw
return Promise.reject(new Error("aborted prematurely before 'listen' event"));
}
this.#stream = new ReadableStream<NativeRequest>({
start: (controller) => {
this.#httpServer = serve?.({
Expand Down

0 comments on commit a05a85b

Please sign in to comment.