Fix: Cannot create BrowserWindow before app is ready #79
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to https://github.com/Automattic/dotcom-forge/issues/6878
Proposed Changes
This PR adds additional
app.isReady()check toapp.on( 'activate')to ensure that the app is ready before it attempts to create a browser window.Testing Instructions
nvm use && npm install && npm startto start the appcmd + Won macOS to close the app window but keep the app runningNotes
I spent some time trying to trigger the error manually but with no luck. It seems that the steps that a user might take to trigger this error would be (since
activateevent is specifically designed for macOS, it would need to be tested on Mac):activateevent starting early before the app is ready by adding something likeapp.emit( 'activate' )early after app initialization but that also did not trigger the error on my end;app.isReady()would need to betruefirst before the BrowserWindow is created. It seems that theactivateevent can possible fire ( https://github.com/Automattic/dotcom-forge/issues/6878#issuecomment-2087334306 ) before thereadyevent so it makes sense to add this guard in that case.If you have any good suggestions on how to test this, let me know!
Pre-merge Checklist