Skip to content

Commit

Permalink
fix(worker): error can be a non-string (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbsp authored Jan 6, 2025
1 parent 3b20a05 commit ba39f03
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions agents/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,19 @@ export class Worker {
try {
await new Promise((resolve, reject) => {
this.#session!.on('open', resolve);
this.#session!.on('error', (error) => reject(error));
this.#session!.on('close', (code) => reject(new Error(`WebSocket returned ${code}`)));
this.#session!.on('error', (error) => reject(error.message));
this.#session!.on('close', (code) => reject(`WebSocket returned ${code}`));
});

retries = 0;
this.#logger.debug('connected to LiveKit server');
this.#runWS(this.#session);
return;
} catch (e) {
} catch (e: unknown) {
if (e instanceof Error || e instanceof ErrorEvent) {
e = e.message;
}

if (this.#closed) return;
if (retries >= this.#opts.maxRetry) {
throw new WorkerError(
Expand Down

0 comments on commit ba39f03

Please sign in to comment.