Skip to content

Wasm32 Compatibility: Unexpected HTTP Range Values When Handling Large Files #11

@HideBa

Description

@HideBa

Description:

I'm developing a Rust library that is primarily designed for native environments but also offers WASM bindings. On the WASM side, I use a HTTP client implementation (via gloo_net) and have implemented the AsyncHttpRangeClient trait from the http-range-client from the crate to fetch data via HTTP range requests.

What I Want to Do:

  • Large File Access in WASM: I aim to efficiently fetch portions of very large files using HTTP range requests in a wasm32 environment, replicating native functionality.
  • Maintain API Interoperability: I wish to keep using the current API by reusing the AsyncBufferedHttpRangeClient and AsyncHttpRangeClient traits without needing to diverge from the existing design.

The Issue:

  • In a wasm32 environment, when the client tries to request a range that exceeds the maximum value of a 32‑bit integer (i.e., beyond u32::MAX), integer overflows occur. This is because, on wasm32, the Rust type usize is interpreted as a 32‑bit value.
  • As a result, HTTP range requests are sent with unexpected values, leading to misaligned or incorrect data being fetched.
  • This behavior seems to be directly linked to the limitations of the wasm32 memory model and its handling of 32‑bit addressable units.

Inquiry:

  • Has anyone encountered this issue in a wasm32 context when handling large file requests?
  • Are there any known workarounds or design suggestions to effectively manage large file offsets while avoiding these integer overflow issues on wasm32?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions