denoland/deno

Uncaught AddrInUse: when using --unstable --watch

rizrmd opened this issue · 8 comments

I tried running simple web server on deno latest:

import { serve } from 'https://deno.land/std/http/server.ts';
const s = serve({ port: 8000 });
console.log('http://localhost:8000/');
for await (const req of s) {
  const file = await Deno.create('f.txt');
  await Deno.copy(req.body, file);
  req.respond({ body: 'Hello  asd asWorld\n' });
}

when I saved some changes, file watcher is restarting my app, and then error:

Watcher File change detected! Restarting!
error: Uncaught AddrInUse: Only one usage of each socket address (protocol/network address/port) is normally permitted. (os error 10048)
    at Object.jsonOpSync (core.js:247:13)
    at opListen (deno:cli/rt/30_net.js:32:17)
    at Object.listen (deno:cli/rt/30_net.js:207:17)
    at Object.listen (deno:cli/rt/40_net_unstable.js:11:18)
    at serve (https://deno.land/std@0.73.0/http/server.ts:287:25)
    at <file:///C:/Users/Riz/Desktop/a/a.ts>:2:1
Watcher Process terminated! Restarting on file change...

I am on windows 10,

I'm using windows 10 too and i have the same problem.
Can somebody help us?

fzn0x commented

I'm also getting this issue by Oak Server , windows 10 , can somebody help?

@rizkyramadhan @mohammadhonarvar @fauzan121002
Do this error still happen to you all when using Deno v1.6.0? If so, I'll dig into it.

@magurotuna
I can confirm this is still happening in v1.6.0.
Environment is Windows 10.

Script is

import { serve } from "https://deno.land/std@0.80.0/http/server.ts";
const s = serve({ port: 8000 });

for await (const req of s) {
  req.respond({ body: "Hello World\n" });
}

Call is:

deno run --allow-net --unstable --watch server.ts

Any change to the script while in watch mode causes the server to crash.

@stefanreimers Thanks for the info! I'll look into it although it seems to be a window specific issue and I don't have a window machine.

By upgrade to version 1.7.0, this issue solved.
Thanks DENO team.

Encountering the same issue on the latest version.

Script is simply:

Deno.serve((_request) => {
    return new Response("Hello world!");
});

Call is:

deno run --watch --unstable --allow-net serve.js

When modifying the script triggering the watcher restart, following error happens:

Uncaught (in promise) AddrInUse: Only one usage of each socket address (protocol/network address/port) is normally permitted. (os error 10048)

Deno 1.27.2 on Windows 10

@jtoppine your problem is tracked in #16267