Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shell.openExternal calls now that it's an async method #8156

Closed
kuychaco opened this issue Aug 23, 2019 · 0 comments · Fixed by #8220 or #8246
Closed

Fix shell.openExternal calls now that it's an async method #8156

kuychaco opened this issue Aug 23, 2019 · 0 comments · Fixed by #8220 or #8246
Assignees
Labels
electron Issues related to our use of Electron that may need updates to Electron or upstream fixes

Comments

@kuychaco
Copy link
Contributor

kuychaco commented Aug 23, 2019

With the upgrade to Electron 5 shell.openExternal is now an async method (see electron/electron#16176).

So we want to update the following accordingly...

const result = shell.openExternal(path)
event.sender.send('open-external-result', { result })

As it is now, we prematurely send the 'open-external-result' event. And we won't be alerted if this operation fails, as we're not handling the promise rejection. From what I can tell we're not actually doing anything with result, so nothing is breaking due to the fact that its value is now a promise rather than a boolean, as was previously returned from shell.openExternal.

To fix this we can either use shell.openExternalSync or await the promise that is now returned from shell.openExternal.

Note that strangely shell.openExternalSync returns a boolean whereas shell.openExternal returns Promise<void>. I'm generally in favor of using the async method, unless we rely on the boolean return value for subsequent logic in our code.

There are several other places that we use shell.openExternal in the code, so we'll want to do a thorough audit and make sure to use the appropriate method in each case.

/cc @vilmibm

@outofambit outofambit added the electron Issues related to our use of Electron that may need updates to Electron or upstream fixes label Aug 23, 2019
@billygriffin billygriffin added this to Backlog in Desktop 2.2 release via automation Sep 4, 2019
@vilmibm vilmibm self-assigned this Sep 4, 2019
@vilmibm vilmibm moved this from Backlog to In Progress in Desktop 2.2 release Sep 4, 2019
Desktop 2.2 release automation moved this from In Progress to Done Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
electron Issues related to our use of Electron that may need updates to Electron or upstream fixes
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants