Skip to content

fix: replace async setInterval with recursive setTimeout in VAD loop and participant polling - #886

Open
Siddh2024 wants to merge 1 commit into
shouri123:mainfrom
Siddh2024:fix/876-async-setinterval
Open

fix: replace async setInterval with recursive setTimeout in VAD loop and participant polling#886
Siddh2024 wants to merge 1 commit into
shouri123:mainfrom
Siddh2024:fix/876-async-setinterval

Conversation

@Siddh2024

Copy link
Copy Markdown
Contributor

Reliability fix: Replace async setInterval with recursive setTimeout in VAD loop and participant polling (#876)

Problem:
setInterval with async callbacks was used in two critical paths:

  1. VAD analysis loop in src/offscreen.ts
  2. Participant polling loop in src/content.ts

This caused:

  • Unhandled promise rejections when async callbacks threw errors
  • Overlapping async executions when callback duration exceeded the interval
  • Timer drift accumulation over long meetings
  • Silent failure mode in participant polling

Changes:

offscreen.ts:

  • Extracted VAD loop logic into dedicated async vadLoop() function
  • Replaced setInterval with recursive setTimeout via vadTimer
  • Removed unused isVadBusy flag (no longer needed - recursive setTimeout naturally serializes)
  • Added proper stop check before scheduling next tick
  • Removed early-return pattern on isVadBusy (no longer applicable)

content.ts:

  • Extracted participant polling into async pollParticipants() function
  • Replaced setInterval with recursive setTimeout via participantPollTimer
  • Added proper error logging with console.debug instead of empty catch
  • Added finally block to ensure next poll is always scheduled
  • Changed clearInterval to clearTimeout in all cleanup paths

Benefits:

  • Async work completes before next tick starts (no overlap)
  • Errors are properly caught and logged
  • Timer drift is eliminated
  • Cleanup is straightforward (just clearTimeout)
  • Production debuggability improved

…and participant polling

Issue shouri123#876 identified two critical issues with async setInterval usage:
1. Unhandled promise rejections when async work in callbacks throws
2. Overlapping async executions when callback duration exceeds the interval

Changes:
- offscreen.ts: Convert VAD analysis loop from setInterval to
  recursive setTimeout pattern via new vadLoop() async function
- content.ts: Convert participant polling from setInterval to
  recursive setTimeout pattern via pollParticipants() async function
- Remove unused isVadBusy flag (no longer needed with recursive
  setTimeout which naturally serializes executions)
- Add proper error logging with console.debug in content.ts polling
- Ensure cleanup functions use clearTimeout instead of clearInterval
@Siddh2024
Siddh2024 requested a review from shouri123 as a code owner July 20, 2026 16:11
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@Siddh2024, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1f66704f-bc08-4c05-9597-dae06f7ee4c2

📥 Commits

Reviewing files that changed from the base of the PR and between d216444 and ecc0392.

📒 Files selected for processing (2)
  • src/content.ts
  • src/offscreen.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Thank You for Contributing to Late-Meet

Please ensure that:

  • the issue was assigned to you before opening this PR
  • the PR references the related issue
  • your changes follow repository contribution guidelines
  • the project builds successfully before submission

Unassigned, duplicate, or low-quality PRs may be closed.

Thank you for contributing 💙

@github-actions github-actions Bot added gssoc Official GSSoC contribution issue gssoc:approved GSSoC: PR approved and scored type:code Type: Code change bug Something isn't working size/M needs-issue and removed gssoc Official GSSoC contribution issue gssoc:approved GSSoC: PR approved and scored labels Jul 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Thank you @Siddh2024 for your contribution to Late-Meet!

⚠️ Warning: This PR does not seem to link to an open issue. Please edit the PR description to include Closes #XX to ensure your contribution counts for GSSoC points.

Please review any automated suggestions or code review comments that may appear below! We will review your PR as soon as possible!


Please consider starring the repository ⭐ to show your support!

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working needs-issue size/M type:code Type: Code change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant