Skip to content

Commit 2457971

Browse files
committed
fix: Catch unhandled promise rejections in worker start() method
1 parent 58916c0 commit 2457971

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

packages/durabletask-js/src/worker/task-hub-grpc-worker.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,13 @@ export class TaskHubGrpcWorker {
158158
const client = new GrpcClient(this._hostAddress, this._grpcChannelOptions, this._tls, this._grpcChannelCredentials);
159159
this._stub = client.stub;
160160

161-
// do not await so it runs in the background
162-
this.internalRunWorker(client);
161+
// Run in background but catch any unhandled errors to prevent unhandled rejections
162+
this.internalRunWorker(client).catch((err) => {
163+
// Only log if the worker wasn't stopped intentionally
164+
if (!this._stopWorker) {
165+
this._logger.error(`Worker error: ${err}`);
166+
}
167+
});
163168

164169
this._isRunning = true;
165170
}

0 commit comments

Comments
 (0)