deno icon indicating copy to clipboard operation
deno copied to clipboard

Can't the "--watch" option be used on a listening port?

Open dong-lufei opened this issue 2 years ago • 2 comments

/**
* deno.jsonc
*/
{
  "tasks": {
    "dev": "deno run -A --watch main.js"
  },
  "imports": {
    "koa": "npm:[email protected]",
    "koa-router": "npm:[email protected]",
    "koa-static": "npm:[email protected]"
  }
}
/**
* main.js
*/
import Koa from "koa"
import Router from "koa-router"

const app = new Koa()
const router = new Router()
router.prefix("/api")

router.get("/", (ctx, _next) => {
  console.log("home1")
  ctx.body = {
    msg: "hello world!",
  }
})

app
  .use(router.routes())
  .use(router.allowedMethods())
  .listen(1993, err => {
    if (err) throw err
    console.log("http://localhost:1993/api")
  })

After running deno task dev, it is normal for the first time, and then change the content of main.js, for example, change console.log("home") to console.log("home2"), and an error will be reported on the terminal: Watcher File change detected! Restarting! error: Uncaught AddrInUse: 通常每个套接字地址(协议/网络地址/端口)只允许使用一次。 (os error 10048) Watcher Process finished. Restarting on file change...

dong-lufei avatar Feb 02 '23 02:02 dong-lufei

Deno uses npm's koa, and when the mouse hovers over its methods or properties, there is no hint of its API usage

dong-lufei avatar Feb 02 '23 02:02 dong-lufei

This is a known bug, hopefully it is fixed soon. https://github.com/denoland/deno/issues/16267

jtoppine avatar Feb 02 '23 09:02 jtoppine

This was fixed in v1.32.4.

bartlomieju avatar Apr 14 '23 00:04 bartlomieju