jgkaplan / gemini-server

Node server for the gemini protocol, based on express
ISC License
65 stars 9 forks source link

HTTP Requests Crash The Server #31

Open matdombrock opened 1 year ago

matdombrock commented 1 year ago

Making an HTTP request to the server causes a crash.

node:internal/errors:478
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_URL]: Invalid URL
    at new NodeError (node:internal/errors:387:5)
    at URL.onParseError (node:internal/url:565:9)
    at new URL (node:internal/url:641:5)
    at Server.<anonymous> (/home/user/Lab/gemini/node_modules/gemini-server/dist/lib/index.js:174:37)
    at step (/home/user/Lab/gemini/node_modules/gemini-server/dist/lib/index.js:40:23)
    at Object.next (/home/user/Lab/gemini/node_modules/gemini-server/dist/lib/index.js:21:53)
    at /home/user/Lab/gemini/node_modules/gemini-server/dist/lib/index.js:15:71
    at new Promise (<anonymous>)
    at __awaiter (/home/user/Lab/gemini/node_modules/gemini-server/dist/lib/index.js:11:12)
    at TLSSocket.<anonymous> (/home/user/Lab/gemini/node_modules/gemini-server/dist/lib/index.js:116:54) {
  input: 'GET / HTTP/1.1',
  code: 'ERR_INVALID_URL'
}

I tried to handle this with middleware but it seems like its happening before the the middleware is called.

To clarify, I really dont know why people are making HTTP requests to port 1965 but they are. My server crashes from this daily.

matdombrock commented 1 year ago

Pull Request

I made PR #32 to address this.

jgkaplan commented 1 year ago

I haven't been able to reproduce this issue. How are you making the HTTP request, and can you show me an example of your server file?

jgkaplan commented 1 year ago

I was actually able to reproduce this with a gemini request as well. I'll look into it more

jgkaplan commented 1 year ago

I think the error is in building the URL object. I'll fix this soon.

jgkaplan commented 1 year ago

I pushed a change that catches a URL parsing failure. Does that fix your issue with HTTP requests as well?