Skip to content

Memory leak: Uncleaned timeouts, intervals, and subscriptions #9156

Closed

Description

@sauerdaniel

Problem

Several small memory leaks exist across the codebase from uncleaned timeouts, intervals, and event subscriptions:

WebFetch Timeout (webfetch.ts)

When fetch throws an error, the timeout is not cleared:

const timeout = setTimeout(...)
try {
  const response = await fetch(...)
} catch (error) {
  // timeout still running!
  throw error
}

Models setInterval (models.ts)

A setInterval is created for model refresh but never cleared:

// Interval runs forever, even after module unload
setInterval(() => refreshModels(), 60000)

Bus.subscribe (github.ts)

The unsubscribe function returned by Bus.subscribe() is not captured:

// Subscription can never be unsubscribed
Bus.subscribe(Event, handler)

Impact

  • Timeouts continue running after errors
  • Intervals run indefinitely
  • Subscriptions cannot be cleaned up

Relates to #5363

Expected Behavior

  • Timeouts should be cleared in finally blocks
  • Intervals should be cleared on process exit
  • Subscription unsubscribe functions should be captured

Activity

  1. added
    perfIndicates a performance issue or need for optimization
    on Jan 17, 2026
  2. github-actions commented on Jan 17, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  3. sauerdaniel commented on Feb 16, 2026

    @sauerdaniel
    ContributorAuthor

    Status: fix is implemented in PR #9148. Remaining blocker is CI on e2e (windows) (NotFoundError), which cascades to the linux gate.

  4. thdxr commented on Apr 2, 2026

    @thdxr
    Member

    Closing in favor of #20695 where we're collecting all memory-related problems. Please follow that issue for updates.

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

Metadata

Metadata

Assignees

Labels

perfIndicates a performance issue or need for optimization

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions