Skip to content

usePermission subscribes after unmount and accepts stale query results #1719

Description

@sridharkalaibala

usePermission does not invalidate an outstanding navigator.permissions.query() when its effect is cleaned up.

I reproduced two cases against master 2ca6f6c using the existing React hook test runner and manually resolved query promises:

  1. Mount the hook, unmount before the query resolves, then resolve it. PermissionStatus.addEventListener('change', ...) is still called, but the cleanup that would remove it has already run.
  2. Start a geolocation query, rerender with notifications, resolve notifications to granted, then resolve the earlier geolocation query to denied. The hook returns denied from the stale query and subscribes to that old status.

Expected: ignore a query result whose effect has been cleaned up, while retaining normal subscription cleanup for a query that resolves while active.

The regression tests fail on both cases; existing DOM/SSR cases and the resolved-query cleanup control pass. I am preparing a focused fix with an effect-local active flag, without changing the public state union, permission API availability policy, or query rejection behavior. This is separate from #1711 (missing Permissions API) and #1563 (Safari change notifications). No physical-device reproduction is claimed.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions