devashishdxt / tonic-web-wasm-client

Other
104 stars 28 forks source link

Error reading status for request which has thrown 503 #40

Closed stan-irl closed 1 year ago

stan-irl commented 1 year ago

Hi. I'm calling into my backend server which is throwing a 503 for some reason. It doesnt look like tonic-web-wasm-client handles it super gracefully. I'm getting the error TypeError: Cannot read properties of undefined (reading 'status') and I think its coming from here

The callstack is as follows:

at logError
at __wbg_status_d2b2d0889f7e970f 
at web_sys::features::gen_Response::Response::status::hd55a446493dd6c3d
at tonic_web_wasm_client::call::call::{{closure}}::hd6b1e448d3a9b412 

I can see a status code in the network inspector which says 503 so im not super sure how we land here

image

what do you think?

devashishdxt commented 1 year ago

Hi. In my local testing with a server that returns 503 on every request, I can see following error:

js api error: TypeError: Failed to fetch

Can you post your server code so that I'm able to reproduce your error?

Here's a simple server that I used to test this:

const express = require('express');
const app = express();

app.use((req, res) => {
    res.sendStatus(503);
});

const port = 50051;
app.listen(port, () => {
    console.log(`Server is running on http://localhost:${port}`);
});
stan-irl commented 1 year ago

Its a server that doesnt support HTTP1 with envoy in front of it. It returns upstream connect error or disconnect/reset before headers. reset reason: remote reset

I think you need to run the wasm client from the browser to repro.

have you tested this library much from the browser? I wrote a whole bunch of code that was running fine in the test runner - it was able to connect to my grpc web server and everything was working, then when i bundled it with wasm-pack and started using it in the browser some stuff has broken.

Im going to open another issue for that other stuff

stan-irl commented 1 year ago

sorry its me not you.

the web dev who wrote the site im integrating into overrode fetch with his own implementation. i just found it.

Sorry to waste your time.