-
Notifications
You must be signed in to change notification settings - Fork 994
Description
- This only affects the JavaScript OpenTelemetry library
- This may affect other libraries, but I would like to get opinions here first
Hi 👋
@opentelemtry/exporter-collector by default adds event listener for the unload event on browser platforms.
According to MDN it can hurt website's performance when doing back/forward buttons:
Additionally, the unload event is incompatible with the back/forward cache (bfcache) implemented in modern browsers. Some browsers, such as Firefox, handle this incompatibility by excluding pages from the bfcache if they contain unload handlers, thus hurting performance.
See Avoid unload and beforeunload for more.
Also I'm not sure what's the purpose of this behaviour? shutdown only returns a promise of already exported items, so doing it on unload doesn't make more sense, does it? See the code I'm referring to.
Additionally, onShutdown is empty for node platform, so we could just remove the onInit and onShutdown functionalities. Am I missing something?