I was attempting to send a http request and got some weird bugs...
This is the minimal example of the buggy behavior
I build and run with roc dev --linker=legacy
app [Model, server] { pf: platform "https://github.com/roc-lang/basic-webserver/releases/download/0.10.0/BgDDIykwcg51W8HA58FE_BjdzgXVk--ucv6pVb_Adik.tar.br" }
import pf.Http
Model : {}
server = { init: Task.ok {}, respond }
respond = \_, _ ->
dbg "req"
{ Http.defaultRequest & url: "https://z.4a.si/spam/objave/" }
|> Http.send
# |> Task.map .body
|> Task.attempt
\x ->
aa = Inspect.toStr x
dbg x
dbg aa
Task.ok { body: "Womp womp" |> Str.toUtf8, headers: [], status: 500 }
Thanks in advance for informing me of my mistakes :)
This sample seems to be working when i replace the domain with google.com ?
Does your request to "https://z.4a.si/spam/objave/" work if you use curl?
Anton said:
Does your request to "https://z.4a.si/spam/objave/" work if you use curl?
Yes, and even if it didn't that should not cause a segfault?
I wonder if it is something about the result returned from that endpoint
Can you post the result from curl
here?
I'm going to assume this fails on the Inspect.toStr x
Might be just too big of a http response?
If you place your dbg before that
Well curl says it's empty....
Anthony Bullard said:
Well curl says it's empty....
I get 26K of data
I guess my friend must be blocking non slovenian IPs
:/
am workin on uploading the curls
Curl -vvvvv URL
STDOUT: https://ass.si/f/ixaf8
STDERR: https://ass.si/f/4-3s4
Sorry, could you post to a GH gist? I am not in the habit of clicking links to random servers I don't know :-)
Anthony Bullard said:
Sorry, could you post to a GH gist? I am not in the habit of clicking links to random servers I don't know :-)
Fair enough, here's a paste bin: https://pastebin.com/TvUz9i08 (STDOUT)
https://pastebin.com/EdhedARE (STDERR)
Thanks! Interesting.....There is nothing that is obviously wrong there. Hopefully we don't segfault on handling multiple packets :rofl:
I have a lot on my plate right now, so can't dig in deep. But hopefully that information is helpful for someone with better knowledge of the HTTP module implementationn
I think there was a regression somewhere, because i have already produced a binary, that works with this code :/
Can you let us know when was the last time the Roc compiler produced a working binary with this code?
I think my build was on 2024-06-25 but i didn't exactly build this project every day, so some versions could still be working after this date
image.png
image.png
The definition orders don't match, im surprised that they aren't important :shrug:
Sure but that helps limit a bisect
That is curious
Have you updated the platform version?
Im looking this up on github
both on master branch
Yeah, sorry, I lost my mind there for a sec
as for my project, i think i have the latest release
Dw, happens to the best of us
But they are named fields so I don't think that order would matter until we get to Mono
Maybe i missed the translating code from one to another, i just assumed it was a ptr cast. Even if this was problematic, it would cause the same problem for google.com as for z.4a.si
Yep
This is what roc's request looks like.
GET /spam/objave/ HTTP/1.1
content-type:
content-length: 0
accept: */*
host: z.4a.si:80
and the nginx response:
read(net): Connection reset by peer
It seems that the problem is the space after : on line content-type:
Adrian has marked this topic as resolved.
So default request doesn’t set a content-type?
Adrian has marked this topic as unresolved.
Anthony Bullard said:
So default request doesn’t set a content-type?
It doesn't, but I found out my testing method was flawed
The problem is on roc-s side
I have wireshark packet caps, that show receiving a "valid response", and then roc segfaults
It seems to also break while requesting "http://www.gstatic.com/generate_204"
Will open a bug report
Thank you for the repro, I'll check this with the new purity inference upgrade I've been working on.
Haven't got hello world working yet, also suffering a segfault somewhere. But hopefully we can figure that out.
Last updated: Jul 06 2025 at 12:14 UTC