aboutsummaryrefslogtreecommitdiff
path: root/examples/http-stop.ts
diff options
context:
space:
mode:
Diffstat (limited to 'examples/http-stop.ts')
-rw-r--r--examples/http-stop.ts10
1 files changed, 4 insertions, 6 deletions
diff --git a/examples/http-stop.ts b/examples/http-stop.ts
index 64d3abfa1..f31dac616 100644
--- a/examples/http-stop.ts
+++ b/examples/http-stop.ts
@@ -1,12 +1,10 @@
const server = Bun.serve({
fetch(req: Request) {
- return new Response(`Pending requests: ${this?.pendingRequests ?? 0}`);
+ return new Response(`Pending requests: ${this.pendingRequests}`);
},
});
+// Stop the server after 5 seconds
setTimeout(() => {
- // stop the server after the first request
- // when the server is stopped, this becomes undefined
- server?.stop();
- console.log("Stopping the server...");
-}, 1000);
+ server.stop();
+}, 5000);