Skip to content

Permissions policy violation: unload event listener triggers Chrome warning #219

@Bre77

Description

@Bre77

Description

The @hyperdx/browser package registers a window.addEventListener("unload", ...) listener in its log exporter, which triggers a Chrome Permissions Policy violation:

[Violation] Permissions policy violation: unload is not allowed in this document.

This occurs on every page load when the HyperDX browser SDK is initialized.

Location

The offending code is in the bundled log exporter, which contains:

window.addEventListener("unload", (() => {
  // flush logs
}));

There is also a beforeunload listener in the page-visibility instrumentation.

Context

Chrome has been deprecating the unload event and enforcing it via Permissions Policy. The unload event is unreliable on mobile and modern browsers increasingly block it entirely.

The library already registers pagehide and visibilitychange listeners elsewhere, which are the recommended replacements.

Expected Behavior

The SDK should not register unload event listeners. The log flush on page exit should use visibilitychange (with document.visibilityState === 'hidden') or pagehide instead, which the library already uses in other places.

Environment

  • @hyperdx/browser: ^0.22.0
  • Chrome 133+
  • Nuxt 4 SSR application

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