Skip to content

Commit

Permalink
More robust fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 committed Aug 1, 2024
1 parent 64853b5 commit 1c6c2b6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions langchain-core/src/utils/signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ export async function raceWithSignal<T>(
return Promise.race([
promise,
new Promise<never>((_, reject) => {
// Must be inside of the promise to avoid a race condition
signal.addEventListener("abort", () => reject(new Error("Aborted")));
// Must be here inside the promise to avoid a race condition
if (signal.aborted) {
return reject(new Error("Aborted"));

Check failure on line 14 in langchain-core/src/utils/signal.ts

View workflow job for this annotation

GitHub Actions / Check linting

Return values from promise executor functions cannot be read
}
signal.addEventListener("abort", () => reject(new Error("Aborted")));
}),
]);
}

0 comments on commit 1c6c2b6

Please sign in to comment.