Skip to content

Commit

Permalink
feat: expose error messages to the client
Browse files Browse the repository at this point in the history
Having the Best client show an error such as:

  `Error: Error running benchmark [object Object]`

is not very useful.
  • Loading branch information
sf-v committed Dec 4, 2022
1 parent db94c84 commit c030be4
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/@best/agent-hub/src/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export class Hub extends EventEmitter {
await remoteAgent.runBenchmarks(remoteClient);
} catch (err) {
console.log(`[HUB] Error running benchmark for remote client ${remoteClient.getId()}`);
remoteClient.disconnectClient(`Error running benchmark ${err}`); // make sure we disconnect the agent
remoteClient.disconnectClient(`Error running benchmark: ${(err as Error).message}`); // make sure we disconnect the agent
} finally {
this.activeClients.delete(remoteClient);
queueMicrotask(() => this.runQueuedBenchmarks());
Expand Down
2 changes: 1 addition & 1 deletion packages/@best/agent/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class Agent extends EventEmitter {
} catch (err) {
console.log(`[AGENT] Error running benchmark for remote client ${remoteClient.getId()}`);
console.log(err);
remoteClient.disconnectClient(`Error running benchmark ${err}`); // make sure we disconnect the agent
remoteClient.disconnectClient(`Error running benchmark: ${(err as Error).message}`); // make sure we disconnect the agent
} finally {
this.state = AgentState.IDLE;
this.interruption = undefined;
Expand Down
2 changes: 1 addition & 1 deletion packages/@best/agent/src/remote-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default class RemoteClient extends EventEmitter implements RunnerStream {
// Notify upload updates
this.emit(BEST_RPC.REMOTE_CLIENT_UPLOAD_COMPLETED);
} catch (err) {
this.disconnectClient(err as any);
this.disconnectClient((err as Error).message);
this._requestJobError(err);
} finally {
this.state = RemoteClientState.IDLE;
Expand Down
2 changes: 1 addition & 1 deletion packages/@best/runner-remote/src/runner-remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class RunnerRemote {
const uploader = await this._getUploaderInstance();
uploader.upload(tarBundle);
} catch (err) {
return this._triggerBenchmarkError(err);
return this._triggerBenchmarkError((err as Error).message);
}
});
}
Expand Down

0 comments on commit c030be4

Please sign in to comment.