Skip to content

wasm-sdk: DAPI requests go to https://host:1443//org.dash.platform.dapi.v0... (double slash), which only gateways that merge slashes route #5275

Closed

Description

@PastaPastaPasta

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-client keeps each node as an http::Uri (address_list.rs L40-L48). http::Uri's string form of https://host:1443 is https://host:1443/.
  • The wasm transport builds its client from that string (wasm_channel.rs L25-L30, L38-L43).
  • tonic-web-wasm-client 0.9.1 (the version in the lockfile, Cargo.lock L8152-L8153) does base_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 is https://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 at https://example.org/dapi/.
  • Or join the base URL and the request path without doubling the slash in tonic-web-wasm-client itself. 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)

  1. In a browser, create an EvoSDK client with an address such as https://<evonode>:1443 and run any read, e.g. sdk.system.status().
  2. In the developer tools' network tab, the request goes to https://<evonode>:1443//org.dash.platform.dapi.v0.Platform/getStatus.
  3. 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 and malformed 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"
done

Context

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

Activity

  1. added
    bug
    js-sdk
    on Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugjs-sdk

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions