Replies: 5 comments
-
|
Node has a similar issue with |
Beta Was this translation helpful? Give feedback.
-
@Seally Thanks for your answer. The problem is I put 5 secondes delay before exit(), so I should receive the response before because if I execute the same code without the exit I got the response.body in few ms. For the oak#closing-the-server I do it but the process is still alive, that the reason why in my closeSocket() function I close the web server listening then close the deno process. |
Beta Was this translation helpful? Give feedback.
-
|
In Node, the process exits naturally if (quoting the docs) "there is no additional work pending in the event loop." I'm not sure how Deno handles it, but I expect it to be similar. Instead of calling What happens if you simply don't have import { Application, Router } from "https://deno.land/x/oak/mod.ts";
const app = new Application();
const controller = new AbortController();
const { signal } = controller;
const router = new Router();
router.get("/reboot", () => {
controller.abort();
});
app.use(router.routes());
app.use(router.allowedMethods());
await app.listen({ port: 8000, signal }); |
Beta Was this translation helpful? Give feedback.
-
|
@Seally This is what I'm going to do, I will just kill the websocket and not the process cause after my function the PC is supposed to reboot so will kill deno process. And the Deno.exit() seems to don't close the process (I still need to ctrl v on console to go out) |
Beta Was this translation helpful? Give feedback.
-
|
I just published an article explaining and showing in examples how I close my oak server which I started from my custom CLI using |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I setup a web server with Oak and I have a specific route where the route return a JSON then close the socket and close the process.
My route is :
The modules.reboot return the JSON with a "4" in the console after the ctx.response.body.
The function closeSocket() :
I added some delay to do some experimentation. Here the console log of the app :
Here we can see the response body is supposed to be sent and now proceed to kill the server listen and then kill the process.
The issue is I don't receive the JSON from the request. If I'm not wrong when I open the console from Chrome I can see the request, I can see the request header and also a response header but no body.
Request Headers :
Response Headers :
I don't know if I made any mistakes or deno issue or oak issue.
Beta Was this translation helpful? Give feedback.
All reactions