Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsr:@std/http/file-server stucks the compiled programs. #4658

Closed
Dreagonmon opened this issue Apr 29, 2024 · 3 comments
Closed

jsr:@std/http/file-server stucks the compiled programs. #4658

Dreagonmon opened this issue Apr 29, 2024 · 3 comments
Labels
bug Something isn't working http

Comments

@Dreagonmon
Copy link

Dreagonmon commented Apr 29, 2024

When using the serveDir from jsr:@std/http/file-server, and compile the script using deno compile, the compiled program won`t start running.

Steps to Reproduce

main.ts

console.log("before everything");
import { serveDir } from "@std/http/file-server";
const handler: Deno.ServeHandler = async (req, _info) => {
  // static server
  return serveDir(req, {
    fsRoot: "./",
  });
};
const __main__ = async () => {
  // start server
  const server = Deno.serve({
    hostname: "0.0.0.0",
    port: 8000,
  }, handler);
};
// Learn more at https://deno.land/manual/examples/module_metadata#concepts
if (import.meta.main) {
  await __main__();
}

deno.json

{
  "tasks": {
    "dev": "deno run --watch --allow-read --allow-net main.ts",
    "compile-run": "deno compile --allow-read --allow-net --output main_exec main.ts && ./main_exec"
  },
  "imports": {
    "@std/http/file-server": "jsr:@std/http@^0.224.0/file-server"
  }
}

Compile and run: deno task compile-run

And the output is:

Task compile-run deno compile --allow-read --allow-net --output main_exec main.ts && ./main_exec
Check file:///home/dreagonmon/Data/Temp/deno_test/main.ts
Compile file:///home/dreagonmon/Data/Temp/deno_test/main.ts to main_exec
Archive:  /tmp/.tmpk2MG2L/denort.zip
  inflating: denort

And it stucks here, no console output, the http server also not started.

Expected behavior

Change the import map:

{
  "tasks": {
    "dev": "deno run --watch --allow-read --allow-net main.ts",
    "compile-run": "deno compile --allow-read --allow-net --output main_exec main.ts && ./main_exec"
  },
  "imports": {
    "@std/http/file-server": "https://deno.land/std@0.224.0/http/file_server.ts"
  }
}

Compile and run: deno task compile-run

The output is:

Task compile-run deno compile --allow-read --allow-net --output main_exec main.ts && ./main_exec
Check file:///home/dreagonmon/Data/Temp/deno_test/main.ts
Compile file:///home/dreagonmon/Data/Temp/deno_test/main.ts to main_exec
Archive:  /tmp/.tmpKDsYIB/denort.zip
  inflating: denort                  
before everything
Listening on http://localhost:8000/

Environment

  • OS: Linux 6.6.26-1-MANJARO
  • deno version: deno 1.42.4 (release, x86_64-unknown-linux-gnu)
  • std version: 0.224.0
@Dreagonmon Dreagonmon added bug Something isn't working needs triage labels Apr 29, 2024
@iuioiua
Copy link
Collaborator

iuioiua commented Apr 29, 2024

I replicated this issue on my macOS machine when using Deno 1.42.4. However, the problem appears fixed when using Deno canary, meaning bug fixes will soon be released in 1.43.0. Can you please upgrade to Deno canary, using deno upgrade --canary, and test again?

@iuioiua iuioiua added http and removed needs triage labels Apr 29, 2024
@kt3k
Copy link
Member

kt3k commented Apr 29, 2024

probably the same issue as denoland/deno#23551 and denoland/deno#23139

resolved in denoland/deno#23567

@Dreagonmon
Copy link
Author

Can you please upgrade to Deno canary, using deno upgrade --canary, and test again?

Yes, the new version seems fixed this bug, 1.43.0(canary) works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working http
Projects
None yet
Development

No branches or pull requests

3 participants