Skip to content

Fix AbortController timer leaks in fetch timeout paths#37

Merged
groupthinking merged 2 commits intoclaude/slack-check-status-update-R47Phfrom
copilot/sub-pr-33-yet-again
Feb 27, 2026
Merged

Fix AbortController timer leaks in fetch timeout paths#37
groupthinking merged 2 commits intoclaude/slack-check-status-update-R47Phfrom
copilot/sub-pr-33-yet-again

Conversation

Copy link
Contributor

Copilot AI commented Feb 27, 2026

clearTimeout was called after await fetch(...) in both /api/video and /api/transcribe, meaning timers were never cleared when the request aborted or threw a network error.

Changes

  • /api/video/route.ts — chain .finally(() => clearTimeout(timeout)) on the backend fetch so the 15s timer is always cleared
  • /api/transcribe/route.ts — same fix for the 8s YouTube backend fetch timeout

Before / After

// Before — timer leaks on abort/throw
const response = await fetch(url, { signal: controller.signal });
clearTimeout(timeout); // never reached if fetch throws

// After — always clears
const response = await fetch(url, { signal: controller.signal })
  .finally(() => clearTimeout(timeout));

Also confirmed in previous commits:

  • transcript_segments correctly handles both transcript[] and transcript.segments[] shapes
  • ENABLE_VERTEX_AI is parsed as a strict boolean ("1" | "true" | "yes") so values like "0" no longer trigger the slow Vertex AI metadata probe

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link
Contributor

vercel bot commented Feb 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
v0-uvai Error Error Feb 27, 2026 10:54pm

@railway-app
Copy link

railway-app bot commented Feb 27, 2026

🚅 Deployed to the EventRelay-pr-37 environment in EventRelay

Service Status Web Updated (UTC)
guides ✅ Success (View Logs) Web Feb 27, 2026 at 10:57 pm
web ✅ Success (View Logs) Web Feb 27, 2026 at 10:55 pm
eslint-config ✅ Success (View Logs) Web Feb 27, 2026 at 10:55 pm
EventRelay ✅ Success (View Logs) Web Feb 27, 2026 at 10:55 pm
supabase ✅ Success (View Logs) Feb 27, 2026 at 10:54 pm

…h abort/error

Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
@railway-app railway-app bot temporarily deployed to EventRelay / EventRelay-pr-37 February 27, 2026 22:53 Destroyed
Copilot AI changed the title [WIP] Add frontend-only video analysis pipeline Fix AbortController timer leaks in fetch timeout paths Feb 27, 2026
Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestion:

Missing Firebase Data Connect SDK module and implicit type errors prevent build compilation

Fix on Vercel

@groupthinking groupthinking marked this pull request as ready for review February 27, 2026 23:03
@groupthinking groupthinking self-requested a review as a code owner February 27, 2026 23:03
Copilot AI review requested due to automatic review settings February 27, 2026 23:03
@groupthinking groupthinking merged commit ebf0327 into claude/slack-check-status-update-R47Ph Feb 27, 2026
8 of 12 checks passed
@groupthinking groupthinking deleted the copilot/sub-pr-33-yet-again branch February 27, 2026 23:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes timer leak bugs where clearTimeout was placed after await fetch(...), meaning timers were never cleared when a fetch threw (e.g., due to network errors or AbortController abort). By replacing the post-await clearTimeout call with .finally(() => clearTimeout(timeout)), the timer is guaranteed to be cleared in all execution paths.

Changes:

  • Moved clearTimeout into .finally() on the backend fetch call in /api/video/route.ts to guarantee the 15s timer always clears.
  • Same fix applied in /api/transcribe/route.ts for the 8s backend fetch timer.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
apps/web/src/app/api/video/route.ts Chains .finally(() => clearTimeout(timeout)) on the backend fetch so the 15s AbortController timer is always cleared
apps/web/src/app/api/transcribe/route.ts Same fix for the 8s AbortController timer guarding the YouTube backend fetch

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants