You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
process.windowsStore returns undefined even in AppX packages in Electron 5.0.x, 7.x, 8.x #18161
process.windowsStore is undefined in both the main and renderer processes when installed as an AppX
Screenshots
I set it up to throw a dialog box of whatever process.windowsStore is
It's obvious from electron itself that it's running from C:\Program Files\WindowsApps
Additional Information
After further testing, I confirmed that this is an issue introduced in Electron 5.0.0. You can test this by cloning the electron-quick-start fork with process.windowsStore checks and changing package.json's "devDependencies">"electron" from "^5.0.0" to "^4.2.0"
Reacted by Steffan Halvorsen, Øyvind Smestad and Mikael Finstad
changed the title [-]process.windowsStore returns undefined even in AppX packages[/-][+]process.windowsStore returns undefined even in AppX packages in Electron 5.0.0[/+]on May 4, 2019
changed the title [-]process.windowsStore returns undefined even in AppX packages in Electron 5.0.0[/-][+]process.windowsStore returns undefined even in AppX packages in Electron 5.0.0, 5.0.1[/+]on May 4, 2019
Yes. nodeIntegration is enabled in both the example and the project I initially ran into the issue on. But remember, it also occurs in the main process.
As I have mentioned before, nodeIntegration is on and there is no documentation as to the API itself changing, being removed, or no longer working, so perhaps it's a good idea to remove the blocked tag.
Let me check that for you! I haven't noticed any issues with other variables thus far, but I'll verify that the others work properly.
Edit: Yes, other properties from process work correctly. both in renderer and main. It is specifically the windowsStore variable that still returns undefined in an AppX.
Hmm, interesting! So that property is set here, and if i uncomment those conditionals it shows up correctly on process so what that tells me is that IsRunningInDesktopBridge() isn't returning the correct bool value in your case. Windows isn't my area of project expertise but I can try to dig some more :)
I had a look at the code myself too, and I suspected that as well, but I couldn't find the IsRunningInDesktopBridge() function myself and I wasn't in the mood to download the whole source tree, so thank you! Haha
For completeness, here's how I tried to solve this (but still failing).
I added this to package.json:
"package-appx": "cross-env FORCE_MS_STORE=true npm run build && electron-builder --win appx",
Added to webpack.config for renderer/main:
new webpack.EnvironmentPlugin({
NODE_ENV: 'production',
FORCE_MS_STORE: process.env.FORCE_MS_STORE || false
}),
I admit, I don't have a good way to test my unsigned appx builds other than submitting them to the store. If I run through a mac build I can verify that setting the env in this way does show up inside the app. So the build logic is sound.
I submitted to MS store and I'm still getting the same behavior. Something else in my build is wrong. (Edit: See below, the workaround is now working for me).
I did end up finding the logs. They are at this location. Hmmm... This means that electron-log is saving to this location, but findLogPath is resolving as somewhere else.
In an attempt to not leave a bunch of open investigations in this thread, it looks like my problem (with applying an env workaround) was twofold.
A recent change in my webpack config was preventing the most recent build of main.prod.js from being bundled into my app.
electron-log had deprecated findLogPath(). Now I'm using: const logPath = log.transports.file.getFile().path;
I'm going to submit and report back in hopefully <36 hours.
Update: Yes, my app is now in the Microsoft Store and it's working with the env workaround described above. It really does seem like windowsStore is not behaving as it should 😞
@zcbenz Thank you for your attention to this issue. I remember that electron v4.x and v6.x did not have this issue, v5.x v8.x process.windowsStore reported wrong results,Haven't tried v7.x。
changed the title [-]process.windowsStore returns undefined even in AppX packages in Electron 5.0.x[/-][+]process.windowsStore returns undefined even in AppX packages in Electron 5.0.x (and some versions of 7 and 8, apparently)[/+]on May 27, 2020
changed the title [-]process.windowsStore returns undefined even in AppX packages in Electron 5.0.x (and some versions of 7 and 8, apparently)[/-][+]process.windowsStore returns undefined even in AppX packages in Electron 5.0.x (as well as 7.x and later, apparently)[/+]on May 27, 2020
changed the title [-]process.windowsStore returns undefined even in AppX packages in Electron 5.0.x (as well as 7.x and later, apparently)[/-][+]process.windowsStore returns undefined even in AppX packages in Electron 5.0.x, 7.x, 8.x[/+]on May 27, 2020
Activity
[-]process.windowsStore[/-][+]process.windowsStore returns undefined even in AppX packages[/+][-]process.windowsStore returns undefined even in AppX packages[/-][+]process.windowsStore returns undefined even in AppX packages in Electron 5.0.0[/+][-]process.windowsStore returns undefined even in AppX packages in Electron 5.0.0[/-][+]process.windowsStore returns undefined even in AppX packages in Electron 5.0.0, 5.0.1[/+]codebytere commentedon May 6, 2019
@dangeredwolf do you have
nodeIntegrationspecifically enabled? As documented, we made a change in5.0.0to disable it by default.dangeredwolf commentedon May 8, 2019
Yes. nodeIntegration is enabled in both the example and the project I initially ran into the issue on. But remember, it also occurs in the main process.
dangeredwolf commentedon May 9, 2019
As I have mentioned before, nodeIntegration is on and there is no documentation as to the API itself changing, being removed, or no longer working, so perhaps it's a good idea to remove the blocked tag.
codebytere commentedon May 9, 2019
@dangeredwolf are other properties on
processcorrectly defined? I see your fork only checks this one specific property.dangeredwolf commentedon May 9, 2019
Let me check that for you! I haven't noticed any issues with other variables thus far, but I'll verify that the others work properly.
Edit: Yes, other properties from process work correctly. both in renderer and main. It is specifically the windowsStore variable that still returns undefined in an AppX.
codebytere commentedon May 9, 2019
Hmm, interesting! So that property is set here, and if i uncomment those conditionals it shows up correctly on
processso what that tells me is thatIsRunningInDesktopBridge()isn't returning the correct bool value in your case. Windows isn't my area of project expertise but I can try to dig some more :)cc @felixrieseberg, you may have more answers here!
dangeredwolf commentedon May 10, 2019
I had a look at the code myself too, and I suspected that as well, but I couldn't find the IsRunningInDesktopBridge() function myself and I wasn't in the mood to download the whole source tree, so thank you! Haha
25 remaining items
mifi commentedon May 20, 2020
I added a PR to update the docs so we don't have more developers going into this trap.
semireg commentedon May 20, 2020
For completeness, here's how I tried to solve this (but still failing).
I added this to package.json:
Added to webpack.config for renderer/main:
I admit, I don't have a good way to test my unsigned appx builds other than submitting them to the store. If I run through a mac build I can verify that setting the env in this way does show up inside the app. So the build logic is sound.
I submitted to MS store and I'm still getting the same behavior. Something else in my build is wrong. (Edit: See below, the workaround is now working for me).
semireg commentedon May 20, 2020
I did end up finding the logs. They are at this location. Hmmm... This means that electron-log is saving to this location, but findLogPath is resolving as somewhere else.
To me, this is indicative of windowsStore being set wrong.
semireg commentedon May 20, 2020
In an attempt to not leave a bunch of open investigations in this thread, it looks like my problem (with applying an env workaround) was twofold.
A recent change in my webpack config was preventing the most recent build of main.prod.js from being bundled into my app.
electron-log had deprecated findLogPath(). Now I'm using:
const logPath = log.transports.file.getFile().path;I'm going to submit and report back in hopefully <36 hours.
Update: Yes, my app is now in the Microsoft Store and it's working with the env workaround described above. It really does seem like windowsStore is not behaving as it should 😞
zcbenz commentedon May 26, 2020
It seems that there is an API for this:
https://docs.microsoft.com/en-us/windows/win32/appxpkg/how-to-query-package-identity-information
I'll see if it can be used.
zcbenz commentedon May 26, 2020
I'm trying to reproduce this issue but it seems that
process.windowsStoreworks correctly with following steps:/electron/electron/resources/app.electron-windows-store --input-directory electron --output-directory out --package-version 1.0.0.0 --package-name electronout/electron.appxand run.Can anyone try the steps above and see if you still see the problem?
mahnunchik commentedon May 26, 2020
@zcbenz @semireg if I understood correctly this happens with the Appx installed from Windows Store.
zcbenz commentedon May 26, 2020
@mahnunchik Do you mean it only happens when the app is submitted to Windows Store?
gaodeng commentedon May 26, 2020
@zcbenz Thank you for your attention to this issue. I remember that electron v4.x and v6.x did not have this issue, v5.x v8.x process.windowsStore reported wrong results,Haven't tried v7.x。
zcbenz commentedon May 27, 2020
@gaodeng Thanks for the information, I'm able to reproduce with 8.x, it seems that 9.x is not affected by the bug.
[-]process.windowsStore returns undefined even in AppX packages in Electron 5.0.x[/-][+]process.windowsStore returns undefined even in AppX packages in Electron 5.0.x (and some versions of 7 and 8, apparently)[/+][-]process.windowsStore returns undefined even in AppX packages in Electron 5.0.x (and some versions of 7 and 8, apparently)[/-][+]process.windowsStore returns undefined even in AppX packages in Electron 5.0.x (as well as 7.x and later, apparently)[/+][-]process.windowsStore returns undefined even in AppX packages in Electron 5.0.x (as well as 7.x and later, apparently)[/-][+]process.windowsStore returns undefined even in AppX packages in Electron 5.0.x, 7.x, 8.x[/+]