Skip to content

New Persistent Context indexes only the first page, and a failed close leaves the persistent context open #5324

Closed

Description

@aaltat

Describe the bug
Two bugs in how Browser handles a persistent context. Both are fixed in #5318.

  1. Only the first page is indexed. New Persistent Context indexed only the first page the context starts with (context.pages()[0]). If the persistent context opened several pages, for example from a restored session, Browser did not know the other pages. Get Page Ids did not list them, and Switch Page could not switch to them.
  2. A failed close leaves the context and its browser on the stack. When closing a persistent context failed, closeContext neither removed the context nor closed the browser that holds it. The browser was also closed without waiting for it, so the keyword could return before the browser was closed.

Fix
Fixed in #5318:

  1. New Persistent Context indexes every page the context starts with. The first page is still the active page.
  2. closeContext closes the browser of a persistent context in a finally block and waits for it, so the browser is removed from the stack even if closing the context fails.

Release notes
These are behaviour changes for persistent contexts:

  • Get Page Ids lists all pages a persistent context starts with, not only the first.
  • When closing a persistent context fails, its browser is still closed and removed.

Found while reviewing #5318 (adoptContext, #5317), which uses the same code for adopted contexts.

Activity

  1. added this to the v20.7.0 milestone on Oct 11, 2026
  2. aaltat commented on Oct 11, 2026

    @aaltat
    MemberAuthor

    #5318 is merged, closing the issue.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions