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
Description
The
@hyperdx/browserpackage registers awindow.addEventListener("unload", ...)listener in its log exporter, which triggers a Chrome Permissions Policy violation: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:
There is also a
beforeunloadlistener in the page-visibility instrumentation.Context
Chrome has been deprecating the
unloadevent and enforcing it via Permissions Policy. Theunloadevent is unreliable on mobile and modern browsers increasingly block it entirely.The library already registers
pagehideandvisibilitychangelisteners elsewhere, which are the recommended replacements.Expected Behavior
The SDK should not register
unloadevent listeners. The log flush on page exit should usevisibilitychange(withdocument.visibilityState === 'hidden') orpagehideinstead, which the library already uses in other places.Environment
@hyperdx/browser:^0.22.0