Am I closing this server wrongly? The port is not free for a new listener! (`AddrInUse`)
3 Replies
Looking at the docs I'd guess so, but it probably needs to sleep for a second for stuff outside of javascript to release it.
Try doing
await new Promise(a => setTimeout(_ => a(true), 0))
just after the server.close()
It does help. Shouldn't Deno take care of it internally? Hopefully with some
Promise
I can wait on to make sure the port is released?
This does work as expected in Node. Meaning I can bring a new server up once the close
event is fired in the old one.Idk. Iām guessing Deno releases it on its end and the OS just needs a bit of time to validate it or whatever.
If sleeping for 0ms worked then you could wrap that Deno close in a promise.