Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app): dont ignore errors in redux robotapi #16128

Merged

Conversation

sfoster1
Copy link
Member

we added the ability for the USB interface to actually pass on communication errors to the browser side, but only some of the things that create those requests on the browser handled it properly. The old redux robot api client didn't. Now it does, at least on USB.

This sort of fixes RQA-3087 in that it will no longer be in the spinner forever and correctly expose the error that happened on the robot, but it doesn't fix it in that you'll now get an error and then a moment later the robot will say it's connected anyway.

Closes RQA-3087 (under the above constraint)

More recent app code uses the api-client direct fetch interface through
react-api-client hooks to talk to the robot, but older app code like
that in the desktop wifi connection uses what came before, an rxjs based
api that you interact with through redux. This API doesn't seem to
properly handle the new errors from the USB interface, so fix that.

This happens in a pretty ugly way because the type interface doesn't
really have the concept of requests that fail without having an http
status code, so we fake one.

Closes RQA-3087
@sfoster1 sfoster1 requested a review from a team as a code owner August 26, 2024 19:11
@sfoster1 sfoster1 requested review from smb2268 and shlokamin and removed request for a team August 26, 2024 19:11
ok: inRange(response?.status, 200, 300),
ok: result.isError
? false
: inRange(result?.response?.status, 200, 300),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upper bound should probably be 400 not 300

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and presumably lower bound should be 100 lol. I'm a bit scared to touch though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh oops you didnt actually change this code, i read the diff wrong

body: result?.response?.data,
// FIXME(sf) this doesn't seem right, but also the type interface isn't written to allow for request
// failures that don't come from valid connections
status: result?.response?.status ?? -1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

up to you but falling back to a 444 rather than -1 seems less likely to cause problems. but actually first, why might we get a rejected promise here? does it mean the connection was closed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or 499

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re: 444 - oh didn't know about that. That's apparently a specific nginx thing? I suppose I'm fine with it

re: why rejected promise - for some reason, maybe something isn't getting passed over ipc correctly, the node-side axios seems to reject on more errors than the browser does. if we're passing in a validator, maybe that's not firing properly. That said, even if axios rejects, the error is very rich and actually has a status code already. Line 82 here should pick up a status from the error if present - that's what the reshaping of the results in the promise then and catch is for, to make sure that both cases have the same shape - but since the error type technically allows the status to be empty in the case of a failed connection, we need some valid default.

Copy link
Member

@shlokamin shlokamin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

man we're getting into weird territory

@sfoster1 sfoster1 merged commit 7406f67 into chore_release-8.0.0 Aug 26, 2024
20 checks passed
@sfoster1 sfoster1 deleted the rqa-3087-fix-ignore-errors-in-redux-robotapi branch August 26, 2024 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants