Repository navigation
Description
In the browser, wasm-sdk / evo-sdk send every DAPI call to a URL with two slashes between the node's address and the gRPC method, for example https://<evonode>:1443//org.dash.platform.dapi.v0.Platform/getDocuments. Evonodes set up with dashmate accept this because dashmate's Envoy merges slashes. A gateway, reverse proxy or CDN in front of DAPI that does not merge slashes may not route the request at all.
We hit this building Dash Forge, a git forge that runs on Platform.
Expected Behavior
The wasm transport sends gRPC-Web requests to <scheme>://<host>:<port>/<package>.<Service>/<Method>, with one slash, the same path the native (tonic) transport uses.
Current Behavior
The base URL handed to tonic-web-wasm-client ends in /, and the client appends a request path that starts with /:
rs-dapi-clientkeeps each node as anhttp::Uri(address_list.rs L40-L48).http::Uri's string form ofhttps://host:1443ishttps://host:1443/.- The wasm transport builds its client from that string (wasm_channel.rs L25-L30, L38-L43).
tonic-web-wasm-client0.9.1 (the version in the lockfile, Cargo.lock L8152-L8153) doesbase_url.push_str(&request.uri().to_string()), where the request URI is/org.dash.platform.dapi.v0.Platform/<Method>(call.rs L14-L19). The result ishttps://host:1443//org.dash…. The latest release, 0.9.2, joins the same way.
A two-line check with http 1.4.2 (the version in the lockfile) shows the join:
let mut base = "https://68.67.122.93:1443".parse::<http::Uri>().unwrap().to_string();
// base == "https://68.67.122.93:1443/"
base.push_str("/org.dash.platform.dapi.v0.Platform/getStatus");
// base == "https://68.67.122.93:1443//org.dash.platform.dapi.v0.Platform/getStatus"We see this on the wire today. A cold load of our web app on a devnet, captured in headless Chromium with @dashevo/evo-sdk 5.0.0-beta.1, requests:
https://<evonode>:1443//org.dash.platform.dapi.v0.Platform/getDocuments
On dashmate-run evonodes it works only because the gateway template sets merge_slashes: true (envoy.yaml.dot L1-L9). Both paths answer 200 on those nodes. Envoy's own default is not to merge slashes, and a gRPC path is defined as /<Service>/<Method>, so other front ends are free to treat //org.dash… as a different path.
We have seen that happen. In late September a devnet's gateway did not merge slashes (Platform 4.2.0-beta.7). It answered the double-slash requests with HTTP 404 and an empty body, and the SDK reported every read as:
transport error: grpc error: code: 'Unknown error', message: "malformed response", source: MalformedResponse
The same request with a single slash answered 200. Once that gateway enabled slash merging, the SDK worked unchanged.
The default branch (v5.0-dev) has the same code. Its last change to wasm_channel.rs is from January 2026.
Possible Solution
Suggestions:
- In
wasm_channel.rs, strip the trailing slash before building the client, e.g.WasmClient::new(uri.to_string().trim_end_matches('/')). Trimming, rather than rebuilding the URL from scheme and authority, keeps working for an address with a path prefix, such as a node behind a proxy athttps://example.org/dapi/. - Or join the base URL and the request path without doubling the slash in
tonic-web-wasm-clientitself. That is an upstream crate, so a local trim is probably quicker.
A unit test asserting the URL that create_channel produces for https://host:1443 and https://host:1443/ would keep it fixed.
Steps to Reproduce (for bugs)
- In a browser, create an
EvoSDKclient with an address such ashttps://<evonode>:1443and run any read, e.g.sdk.system.status(). - In the developer tools' network tab, the request goes to
https://<evonode>:1443//org.dash.platform.dapi.v0.Platform/getStatus. - Put a proxy that does not merge slashes in front of the node (for example Envoy with its default
merge_slashes: false), point the SDK at it, and run the read again. With such a gateway we saw HTTP 404 andmalformed response.
Without a browser, the difference shows with curl (a valid gRPC-Web frame for an empty GetStatusRequest):
printf '\x00\x00\x00\x00\x02\x0a\x00' > req.bin
for p in /org.dash.platform.dapi.v0.Platform/getStatus //org.dash.platform.dapi.v0.Platform/getStatus; do
curl -sk -o /dev/null -w "%{http_code} $p\n" -X POST \
-H 'content-type: application/grpc-web+proto' -H 'x-grpc-web: 1' \
--data-binary @req.bin "https://<gateway>$p"
doneContext
Apps that serve DAPI through their own gateway, for caching, rate limiting or a custom domain, or put a CDN in front of it, get an SDK that fails on every request with a generic malformed response. Nothing points at the URL as the cause. For a while we carried a fetch wrapper that rewrote //org.dash to /org.dash on DAPI requests. We dropped it once the devnet's gateway merged slashes, but an app can't assume that of every front end.
Your Environment
- Version used: Platform 5.0.0-beta.1 on a devnet (sakura);
@dashevo/evo-sdkand@dashevo/wasm-sdk5.0.0-beta.1 from npm. The 404 was seen earlier with 4.2.0-beta.7 on a devnet whose gateway did not merge slashes. - Environment name and version: headless Chromium (the network capture); the 404 was seen from Node.js.
- Operating System and version: macOS.
- Link to your project: https://github.com/PastaPastaPasta/dash-forge
Activity