Skip to content

Commit

Permalink
[RSDK-9165] Stop sessions when unimplemented received (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
njooma authored Oct 30, 2024
1 parent 7ef6879 commit 3aeb2eb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/robot/session-manager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
Code,
ConnectError,
createPromiseClient,
createClient,
type Transport,
} from '@connectrpc/connect';
import { RobotService } from '../gen/robot/v1/robot_connect';
Expand Down Expand Up @@ -32,7 +32,7 @@ export default class SessionManager {

private get client() {
const transport = this.deferredTransport();
return createPromiseClient(RobotService, transport);
return createClient(RobotService, transport);
}

constructor(private deferredTransport: () => Transport) {
Expand Down Expand Up @@ -78,6 +78,14 @@ export default class SessionManager {
try {
await this.client.sendSessionHeartbeat(sendHeartbeatReq);
} catch (error) {
if (
error instanceof ConnectError &&
error.code === Code.Unimplemented
) {
console.error('sessions unsupported; will not try again'); // eslint-disable-line no-console
this.sessionsSupported = false;
return;
}
if (
error instanceof ConnectionClosedError ||
(error instanceof ConnectError && error.rawMessage === 'closed')
Expand Down

0 comments on commit 3aeb2eb

Please sign in to comment.