Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chilled-knives-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@livekit/agents": patch
---

Ensure delay doesn't reject with undefined
4 changes: 2 additions & 2 deletions agents/src/utils.ts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Incomplete fix: early-return path at line 792 still rejects with potentially undefined reason

The PR's intent (per the commit message "Ensure delay doesn't reject with undefined") is to prevent the delay promise from rejecting with undefined. The fix at line 796 adds ?? new Error('delay aborted') as a fallback, but the early-return path at line 792 (return Promise.reject(signal.reason)) has the same problem and was not updated. If signal.reason is undefined (e.g., in older runtimes or polyfills where AbortSignal.reason is not supported), this path will still reject with undefined.

(Refers to line 792)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Original file line number Diff line number Diff line change
Expand Up @@ -789,11 +789,11 @@ export type DelayOptions = {
*/
export function delay(ms: number, options: DelayOptions = {}): Promise<void> {
const { signal } = options;
if (signal?.aborted) return Promise.reject(signal.reason);
if (signal?.aborted) return Promise.reject(signal.reason ?? new Error('delay aborted'));
return new Promise((resolve, reject) => {
const abort = () => {
clearTimeout(i);
reject(signal?.reason);
reject(signal?.reason ?? new Error('delay aborted'));
};
const done = () => {
signal?.removeEventListener('abort', abort);
Expand Down
Loading