oxidecomputer / rfd-site

Web frontend for browsing, searching, and reading RFDs
https://rfd.shared.oxide.computer
Mozilla Public License 2.0
87 stars 4 forks source link

local mode does not come up when `HOST` is not resolvable #18

Open davepacheco opened 1 year ago

davepacheco commented 1 year ago

On my system, HOST=zathras (in the environment). But zathras is not resolvable in DNS. If I run this, it reports this error and then sits there, not having started listening on port 3000:

$ LOCAL_RFD_REPO=... npm run dev

> dev
> remix dev

 💿  remix dev

 info  building...
 warn  esm-only package: @asciidoctor/core
┃ @asciidoctor/core is possibly an ESM-only package.
┃ To bundle it with your server, include it in `serverDependenciesToBundle`
┃ -> https://remix.run/docs/en/main/file-conventions/remix-config#serverdependenciestobundle
â”—
 info  built (10.5s)
Error: getaddrinfo ENOTFOUND zathras
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26)

I was confused about whether this problem was fatal or not. It seems like it basically is but the program doesn't exit. I worked around it by setting HOST=zathras.local.

david-crespo commented 1 year ago

Cool. Seems like this might be fixed in Remix v2, which I am in the process of upgrading to in oxidecomputer/rfd-site-old#238.

v1.19

https://github.com/remix-run/remix/blob/21d22901fdc3e50650c73825fbea171cf6e93ad0/packages/remix-dev/cli/commands.ts#L513-L516

v2

It might always use localhost in dev mode:

https://github.com/remix-run/remix/blob/a20ae7fb0727212ac52bdc687513c61851ac4014/packages/remix-dev/cli/commands.ts#L344-L346

david-crespo commented 1 year ago

I checked and v2 does not fix this, it does the same thing.

~/oxide/rfd-site $ HOST=abc LOCAL_RFD_REPO=~/oxide/rfd npm run dev

> dev
> remix dev

 💿  remix dev

 info  building...
 info  built (4.3s)

Error: getaddrinfo ENOTFOUND abc
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:108:26)

What do you think it should be doing instead? Do you think local dev should always use localhost regardless of the value of HOST? If so, here's the stupid fix we could go with (I don't really see an issue with it):

-    "dev": "remix dev",
+    "dev": "HOST=localhost remix dev",
~/oxide/rfd-site $ HOST=abc LOCAL_RFD_REPO=~/oxide/rfd npm run dev

> dev
> HOST=localhost remix dev

 💿  remix dev

 info  building...
 info  built (4s)

[remix-serve] http://localhost:3000 (http://localhost:3000)
davepacheco commented 1 year ago

I checked and v2 does not fix this, it does the same thing.

~/oxide/rfd-site $ HOST=abc LOCAL_RFD_REPO=~/oxide/rfd npm run dev

> dev
> remix dev

 💿  remix dev

 info  building...
 info  built (4.3s)

Error: getaddrinfo ENOTFOUND abc
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:108:26)

What do you think it should be doing instead? Do you think local dev should always use localhost regardless of the value of HOST? If so, here's the stupid fix we could go with (I don't really see an issue with it):

-    "dev": "remix dev",
+    "dev": "HOST=localhost remix dev",

That seems fine. I don't know enough about Remix to have much opinion. A lot of stuff assumes that a system's hostname is resolvable in DNS, but that's generally not a great assumption. Usually if I want something to listen on anything other than localhost, I want to tell it exactly what. In that sense, I'd rather it didn't look at HOST at all, but 🤷 maybe for most users that's what they want.

I would also be happy with an error message that said that it failed to come up because of this (and ideally where it got the hostname from) and then exiting instead of just hanging. The real reason this was annoying was that I spent time trying to guess if it came up anyway (I noticed it did open port 3001 and tried that) and also guessing where it got zathras from. But it seems like fixing these issues is probably harder than just telling it to use localhost.

Thanks for looking at this!