MindscapeHQ / raygun4js

JavaScript provider for Raygun
https://raygun.com
Other
149 stars 60 forks source link

Fix infinite recursive loop on UMD module init #505

Closed Hamish-taylor closed 1 year ago

Hamish-taylor commented 1 year ago

This PR is to solve an issue first surfaced in issue #473.

The problem

We are assuming rg4js is loaded when document.readyState is marked as complete. However, this is not true, it's not loaded until after the load event has been triggered. According to the spec complete indicates that the load event is about to fire. This leaves a small gap where if our code is executed between the document state being marked as complete and the load event firing, an infinite recursive loop is started that will hang the application.

The fix

The current fix I have in mind for this is to add a variable to the window that is set to true after we know for sure rg4js is initialized. The UMD initialization code will then wait for this rather than document.readyState === 'complete'

PanosNB commented 1 year ago

Both Darcy and Sean have looked into this and ran unit tests.

@Hamish-taylor , do at least the following before releasing: (1) presoaking a prerelease to our website (at least a day ) and (2) also try to deploy a test website that would have triggered the error to test it's ok.

Then, first release on npm and nuget; wait for a couple of days and then release on CDN. Keep CS informed on each step

@CmdrKeen FYI