Do not throw warnings when a service calls disconnects the websocket#8932
Conversation
- Waiting was unreliable since the websocket response could take a few seconds to get delivered - Alternate frontend fix is home-assistant/frontend#8932
…49323) - Waiting was unreliable since the websocket response could take a few seconds to get delivered - Alternate frontend fix is home-assistant/frontend#8932
| const [domain, service] = this._serviceData.service.split(".", 2); | ||
| if ( | ||
| err.error.code === ERR_CONNECTION_LOST && | ||
| serviceCallWillDisconnect(domain, service) |
There was a problem hiding this comment.
This can also work:
| const [domain, service] = this._serviceData.service.split(".", 2); | |
| if ( | |
| err.error.code === ERR_CONNECTION_LOST && | |
| serviceCallWillDisconnect(domain, service) | |
| if ( | |
| err.error.code === ERR_CONNECTION_LOST && | |
| serviceCallWillDisconnect(...this._serviceData.service.split(".", 2)) |
(but is less readable)
| err.error.code === ERR_CONNECTION_LOST && | ||
| serviceCallWillDisconnect(domain, service) | ||
| ) { | ||
| throw err; |
There was a problem hiding this comment.
I wasn't sure how all the existing callers would handle it if they got back nothing instead of the promise so throw + suppressing the notification in the UI seemed like the way to go.
Better ideas?
There was a problem hiding this comment.
I think almost nothing in the frontend uses the return value of callService, I introduced it for the scenes editor a year ago, if they do, Typescript should be able to tell you the issues :-)
If we throw, it will not be caught by the caller, as we previously never thrown errors, but caught errors here. I would return undefined to keep current behavior.
There was a problem hiding this comment.
(and move it after the dev console log)
There was a problem hiding this comment.
Proposed change
Do not throw warnings when a service calls disconnects the websocket
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: