rawhat / mist

gleam HTTP server. because it glistens on a web
Apache License 2.0
333 stars 12 forks source link

Error without a message when deploying to Railway #17

Closed aleksrutins closed 1 year ago

aleksrutins commented 1 year ago

Hello! I'm getting started with Gleam, and I'm trying to build a web app with it. So far, I just have the code from the web server tutorial (plus logic to determine the port based on environment variables), and it's working perfectly well locally. When I try to deploy it to Railway, however, it gives this error whenever I try to access it:

=ERROR REPORT==== 20-Feb-2023::17:59:47.884721 ===
Error in process <0.155.0> with exit value:
{{case_clause,{tcp,fun 'glisten@tcp':accept/1,
fun 'glisten@tcp':accept_timeout/2,
fun 'glisten@tcp':close/1,
fun 'glisten@tcp':controlling_process/2,
fun 'glisten@tcp':handshake/1,fun 'glisten@tcp':listen/2,
#Fun<glisten@socket@transport.0.28262813>,
fun 'glisten@tcp':receive/2,
fun 'glisten@tcp':receive_timeout/3,
fun 'glisten@tcp':send/2,fun 'glisten@tcp':set_opts/2,
fun 'glisten@tcp':shutdown/1,fun socket:info/1}},
[{mist@http,parse_request,3,
[{file,"build/prod/erlang/mist/build/mist@http.erl"},{line,299}]},
{mist@handler,'-with_func/1-fun-6-',3,
[{file,"build/prod/erlang/mist/build/mist@handler.erl"},
{line,42}]},
{glisten@handler,'-start/1-fun-3-',3,
[{file,"build/prod/erlang/glisten/build/glisten@handler.erl"},
{line,169}]},
{gleam@otp@actor,loop,1,
[{file,"build/prod/erlang/gleam_otp/build/gleam@otp@actor.erl"},
{line,113}]}]}

I'm quite new to both Erlang and Gleam, but I don't see a message, and the stack trace isn't of much help as it refers to the intermediate Erlang files.

rawhat commented 1 year ago

Is this over HTTPS when deployed, but HTTP locally? Curious if that's the issue. If so, you may need to conditionally use one of the serve methods depending on another environment variable.

If not, it could be something like permissions for the port, though I think mist would handle that more gracefully. If it's not related to HTTP/S, maybe worth testing the exact request it's making on your local? Perhaps some part of the request is not getting handled properly.

Let me know what you find!

aleksrutins commented 1 year ago

Sorry for taking so long to respond, but I guess something got upgraded and it works now.