fix(shutdown): treat a graceful close that throws synchronously as a rejection
closeWithDeadline called graceful() directly inside the Promise executor. A graceful path that threw before returning its promise escaped the executor, so the close() that serveDeno and serveBun return rejected on the spot. The deadline timer had already been armed and nothing cleared it, so it later fired anyway: it logged a timeout and forced a server whose close() had already given up. graceful() now runs inside Promise.resolve().then(), so a synchronous throw becomes a rejection and takes the same path one already took: the shutdown ends, close() resolves, and the timer is cleared. GitHub #47. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
3 files changed
+29
-2
No files matched your search
@@ -280,6 +280,12 @@ npm treats versions as semver and semver forbids leading zeros.
|
||||
second resolved while a database could still be open. Every caller now gets the promise of the
|
||||
teardown already in flight, and it still runs once.
|
||||
|
||||
- **A graceful close that throws synchronously no longer rejects `close()`** (GitHub #47). On Deno
|
||||
and Bun, `closeWithDeadline` called the graceful path directly, so a throw before it returned a
|
||||
promise escaped as a rejection of `close()`, while the deadline timer stayed armed and later
|
||||
forced the server and logged a timeout nobody was waiting for. A synchronous throw is now handled
|
||||
like a rejection: `close()` resolves, and the timer is cleared.
|
||||
|
||||
- **`listen()` rejects when the port is taken** (#138). A bind failure such as `EADDRINUSE` or
|
||||
`EACCES` arrives as the server's `error` event, which `listen()` did not handle: the promise
|
||||
never settled, and the error surfaced as an unhandled one. It now rejects with that error. The
|
||||
|
||||
Reference in new issue
Block a user