Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 08:23
    caspiano edited #10531
  • Dec 08 23:04
    HertzDevil edited #12623
  • Dec 08 22:57
    Blacksmoke16 edited #9745
  • Dec 08 22:57
    Blacksmoke16 labeled #9745
  • Dec 08 22:57
    Blacksmoke16 labeled #9745
  • Dec 08 22:54
    HertzDevil labeled #12828
  • Dec 08 22:54
    HertzDevil labeled #12828
  • Dec 08 22:54
    HertzDevil opened #12828
  • Dec 08 22:34
    straight-shoota edited #12827
  • Dec 08 22:32
    straight-shoota edited #12827
  • Dec 08 22:29
    straight-shoota labeled #12827
  • Dec 08 22:29
    straight-shoota labeled #12827
  • Dec 08 22:29
    straight-shoota opened #12827
  • Dec 08 22:15
    straight-shoota closed #12814
  • Dec 08 17:12
    straight-shoota assigned #12814
  • Dec 08 17:12
    straight-shoota assigned #12813
  • Dec 08 17:12
    straight-shoota assigned #12809
  • Dec 08 17:12
    straight-shoota assigned #12802
  • Dec 08 17:12
    straight-shoota assigned #12797
  • Dec 08 17:12
    straight-shoota assigned #12664
Mateusz Wieloch
@mateuszwieloch
image.png
Ali Naqvi
@naqvis
Mateusz Wieloch
@mateuszwieloch
🙏🏻Thank you! Looks like it has what I need or at least what I can use as a starting point
Ali Naqvi
@naqvis
:thumbsup:
Ali Naqvi
@naqvis
Published wasmer-crystal WebAssembly runtime for Crystal
Vladislav Zarakovsky
@vlazar
:heart: Wow, that's so cool! So I can use any Rust libs compiled to WASM from Crystal now?
Ali Naqvi
@naqvis
thanks and yeah
:pray:
Vladislav Zarakovsky
@vlazar
A complete and mature WebAssembly runtime
Is "mature" part there about it being tested in prod?
Ali Naqvi
@naqvis
that applies to wasmer
Vladislav Zarakovsky
@vlazar
gotcha, thank you!
Ali Naqvi
@naqvis
:pray:
ddd
@Dan-Do
A silly question as I don't know wasm. Does it mean that we can run Crystal code in browser?
Ali Naqvi
@naqvis
no, you can't compile crystal code to wasm. But via this shard now you can run other wasm modules from Crystal
this shard embeds wasm runtime inside crystal
ddd
@Dan-Do
:thumbsup:
Vladislav Zarakovsky
@vlazar
which means if you miss something in Crystal shards you can check https://crates.io/categories/wasm or anything else that works when compiled to WASM
ddd
@Dan-Do
That's really valuable for the community :heart:
From IRC (bridge bot)
@FromIRC
<SamantazFox> Hmm, I have a weird bug. I'm investigation atm, but the general idea is that because of the decompression issues in HTTP::Client from stdlib
<SamantazFox> I did implement a decompression routine (iv-org/invidious#2623), but it raises the following exception "HTTP::Client::Response#body_io cannot be nil (NilAssertionError)" in some edge cases.
<SamantazFox> I've deployed that fix for a few days now, on bare metal Debian, without a problem. But we keep getting issue reports about it.
<SamantazFox> So I'm trying to figure out if the problem is due to docker, or some specific container.
ddd
@Dan-Do
Regarding the body_io, sometimes the client cannot parse the response. I have a monkey patch like this
class HTTP::Client::Response
  def self.from_io?(io, ignore_body = false, decompress = true, &block)
    line = io.gets(4096, chomp: true)
    return yield nil unless line

    pieces = line.split(3)
    if pieces.size < 2
      # return yield new status_code: 200, body_io: ChunkedContent.new(io)
      pieces = "HTTP/1.1 200 OK".split(3)
    end

    http_version = pieces[0]
    raise "Unsupported HTTP version: #{http_version}" unless HTTP::SUPPORTED_VERSIONS.includes?(http_version)
    status_code = pieces[1].to_i?
    unless status_code && 100 <= status_code < 1000
      raise "Invalid HTTP status code: #{pieces[1]}"
    end

    status = HTTP::Status.new(status_code)
    status_message = pieces[2]? ? pieces[2].chomp : ""
    body_type = HTTP::BodyType::OnDemand
    body_type = HTTP::BodyType::Mandatory if mandatory_body?(status)
    body_type = HTTP::BodyType::Prohibited if ignore_body
    HTTP.parse_headers_and_body(io, body_type: body_type, decompress: decompress) do |headers, body|
      return yield new status, nil, headers, status_message, http_version, body
    end
    nil
  end
end
The patch is
    if pieces.size < 2
      # return yield new status_code: 200, body_io: ChunkedContent.new(io)
      pieces = "HTTP/1.1 200 OK".split(3)
    end
(un)comment the line that works your you
From IRC (bridge bot)
@FromIRC
<SamantazFox> haaaaaaa flails
<SamantazFox> thanks!
<SamantazFox> whyyyy
<SamantazFox> why is the body_io niled?
<yxhuvud> Why does it matter to you?
From IRC (bridge bot)
@FromIRC
<SamantazFox> yxhuvud: because of a bug in the stdlib, a response's body is not always decompressed, and rather than checking if it was properly done, I've made a patch in my code to send the Content-Encoding header, which disables auto decompression, and do that by myself.
<SamantazFox> but, Compress::Gzip::Reader and Compress::Deflate::Reader both takes IOs, not Strings
<yxhuvud> if gets to end has been called, it will be nothing more to decompress anyhow, so it wouldn't matter
<SamantazFox> my problem is that response.body is a String, and I have to feed it to Compress::Gzip::Reader
George Dietrich
@Blacksmoke16
body_io is only set if you're using the block version of one of the request methods
From IRC (bridge bot)
@FromIRC
<SamantazFox> So I though: let's use response.body_io instead, to directly have an IO
George Dietrich
@Blacksmoke16
From IRC (bridge bot)
@FromIRC
<straight-shoota> There is no way to access either body or body_io. They're mutually exclusive
<SamantazFox> That's something I'd expect, yeah, but why body is always the full body, as a String and body_io is that same body as IO, but Nil on Docker?
<straight-shoota> Sorry what has Docker to do with this?
<SamantazFox> I'm trying to figure that out, actually.
<SamantazFox> For context, I've made this code, to prevent an issue from happenning: https://github.com/iv-org/invidious/pull/2623/files
<SamantazFox> Said issue is: "body is sometimes decompressed, sometimes not"
From IRC (bridge bot)
@FromIRC
<SamantazFox> So, I've set "Content-Encoding" to "gzip, deflate" to disable HTTP::Client's auto-decompression, and added the required logic to decompress the body by myself
<SamantazFox> problem is that when deployed on bare-metal, it works fine, and on Docker, we're getting this: iv-org/invidious#2632
George Dietrich
@Blacksmoke16
i mean is it not possible you're doing like HTTP::Client.get "..." then trying to access body_io on it?
From IRC (bridge bot)
@FromIRC
<SamantazFox> response.body_io, yes.