Closed Hexagon closed 1 year ago
I can't reproduce on linux, I can run failure.ts many times without error
Are you sure? The reproduction code fail on both a physical linux machine and codespaces for me.
Codespaces:
deno 1.34.1 (release, x86_64-unknown-linux-gnu)
v8 11.5.150.2
typescript 5.0.4
Local:
deno 1.33.4 (release, x86_64-unknown-linux-gnu)
v8 11.4.183.2
typescript 5.0.4
I made a repo out of it to keep it simple
yeah the repo you linked also work
but funny thing I found, turns out deno lsp listen to port 8084 by default, so that might be the issue ? can you try using a different port ?
or maybe no, let me pr some fixes to that repo, so we can test there more
Can you try here https://github.com/sigmaSd/dax-issue-146 (this makes sure that dax have the latest version) and can you kill -9 deno before starting just for sanity check
Aaah, your version work fine. But it is because the server exit gracefully before dax tries to kill the process, if I add the server code to your version, it starts failing again (because the process is kept alive until it's killed by dax).
// Connections to the server will be yielded up as an async iterable.
for await (const conn of server) {
// In order to not be blocking, we need to handle each connection individually
// without awaiting the function
serveHttp(conn);
}
async function serveHttp(conn: Deno.Conn) {
// This "upgrades" a network connection into an HTTP connection.
const httpConn = Deno.serveHttp(conn);
// Each request sent over the HTTP connection will be yielded as an async
// iterator from the HTTP connection.
for await (const requestEvent of httpConn) {
// The native HTTP server uses the web standard `Request` and `Response`
// objects.
const body = `Your user-agent is:\n\n${
requestEvent.request.headers.get("user-agent") ?? "Unknown"
}`;
// The requestEvent's `.respondWith()` method is how we send the response
// back to the client.
requestEvent.respondWith(
new Response(body, {
status: 200,
}),
);
}
}
I see, this is an issue with abortcontroller , here is a minimal example, I think you should close this issue and open one against deno repo
const control = new AbortController();
const child = new Deno.Command("deno", {
// args: ["run","-A", "main.ts"], // works
args: ["task", "prod"], // fails
signal: control.signal,
}).spawn();
await new Promise((r) => setTimeout(r, 1000));
control.abort();
await child.status;
or maybe its an issue with how deno task works
actually here is the issue already https://github.com/denoland/deno/issues/18445
Ooh, cool. Thanks for checking it up :100:
Ran into a problem on a production pup instance running a web server using command
deno task prod
. Once started, the server cannot be killed programatically. Pup uses dax internally.The problem is solved by starting the server using command deno run instead of deno task.
When aborting
deno task prod
using CTRL+C at the command line, everything works as it should.Complete repro at https://github.com/Hexagon/dax-issue-146
Repro steps
Running deno run -A main.ts directly using dax works fine
Running deno task prod using dax seem to leave the actual deno process hanging
Code for repro
deno.json
main.ts
works.ts
failure.ts