Skip to content

Close webContents automatically when they are no longer referenced #48565

Description

@nikwen

Preflight Checklist

Problem Description

Right now, webContents need to be closed manually. See here.

Proposed Solution

Close webContents automatically when they are no longer referenced in any form.

Alternatives Considered

Continue having to close them manually.

Additional Information

Docs PR that documented having to close the webContents: #43610

Fiddle gist to see that calling close is necessary: https://gist.github.com/nikwen/dacdd75daff9eb17af01fd528cdbdefc

This will be a breaking change.

Activity

  1. Prabhassharma177 commented on Oct 16, 2025

    @Prabhassharma177
  2. nmggithub commented on Feb 2, 2026

    @nmggithub
    Contributor

    Close webContents automatically when they are no longer referenced in any form.

    This would be a bit difficult to track as, from my understanding, these things aren't reference-counted. If anyone ever stores the webContents in another variable, we wouldn't be safe in closing the webContents (but we'd also have no way of knowing when that happens).

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions