meilisearch / meilisearch-rust

Rust wrapper for the Meilisearch API.
https://www.meilisearch.com
MIT License
361 stars 90 forks source link

http panic in wasm due to capitalized header name #580

Closed minijackson closed 5 months ago

minijackson commented 6 months ago

Description

Hello! I'm building a wasm app using meilisearch-sdk, and found this confusing error when calling Client::new:

index out of bounds: the len is 0 but the index is 0

Expected behavior

Client::new does not panic.

Current behavior

Turns out it's http's way of telling us that a header name is capitalized, and panics.

Here's the http code that panics (HeaderName::from_static):

https://github.com/hyperium/http/blob/v1.1.0/src/header/name.rs#L1197-L1224

And I think the X-Meilisearch-Client is what causes it:

https://github.com/meilisearch/meilisearch-rust/blob/v0.26.0/src/reqwest.rs#L35

Environment (please complete the following information):

DimitriTimoz commented 6 months ago

As specified in this seanmonstar/reqwest#630 response headers implementation is not officially supported in reqwest. web_sys should be used for every request to be sure of wasm support.
I guess someone broke it recently.

irevoire commented 5 months ago

Hey @minijackson,

Could you retry your app with this branch and let me know if everything works: https://github.com/meilisearch/meilisearch-rust/pull/582 I’m struggling to run the example in this repo