gemini-server icon indicating copy to clipboard operation
gemini-server copied to clipboard

HTTP Requests Crash The Server

Open matdombrock opened this issue 1 year ago • 5 comments

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 avatar May 10 '23 07:05 matdombrock

Pull Request

I made PR #32 to address this.

matdombrock avatar May 10 '23 07:05 matdombrock

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 avatar May 10 '23 17:05 jgkaplan

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

jgkaplan avatar May 10 '23 17:05 jgkaplan

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

jgkaplan avatar May 10 '23 17:05 jgkaplan

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

jgkaplan avatar May 10 '23 18:05 jgkaplan