Skip to content

process.windowsStore returns undefined even in AppX packages in Electron 5.0.x, 7.x, 8.x #18161

Closed

Description

@dangeredwolf

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    • Tested on electron 5.0.0, through 5.0.6
  • Operating System:
    • Windows 10 (Tested on both 1803 and 1809)

Expected Behavior

process.windowsStore should return true if running inside of an appx package, as described in https://electronjs.org/docs/api/process#processwindowsstore

Actual Behavior

process.windowsStore returns undefined, even when running in an appx package

To Reproduce

I forked electron-quick-start to demonstrate the issue I found.
https://github.com/dangeredwolf/electron-quick-start

You can then use npm run buildWindows to create the appx.

If you're unfamiliar with appx deployment, appx files need to be signed to be installed, even in developer mode. This is basically how to do that (from Microsoft's docs)

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

image

It's obvious from electron itself that it's running from C:\Program Files\WindowsApps

image

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"

image

Activity

  1. changed the title [-]process.windowsStore[/-] [+]process.windowsStore returns undefined even in AppX packages[/+] on May 4, 2019
  2. 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
  3. 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
  4. codebytere commented on May 6, 2019

    @codebytere
    Member

    @dangeredwolf do you have nodeIntegration specifically enabled? As documented, we made a change in 5.0.0 to disable it by default.

  5. added
    blocked/need-info ❌
    on May 7, 2019
  6. dangeredwolf commented on May 8, 2019

    @dangeredwolf
    Author

    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.

  7. dangeredwolf commented on May 9, 2019

    @dangeredwolf
    Author

    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.

  8. added and removed
    blocked/need-info ❌
    on May 9, 2019
  9. codebytere commented on May 9, 2019

    @codebytere
    Member

    @dangeredwolf are other properties on process correctly defined? I see your fork only checks this one specific property.

  10. dangeredwolf commented on May 9, 2019

    @dangeredwolf
    Author

    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.

  11. codebytere commented on May 9, 2019

    @codebytere
    Member

    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 :)

    cc @felixrieseberg, you may have more answers here!

  12. dangeredwolf commented on May 10, 2019

    @dangeredwolf
    Author

    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

  13. 25 remaining items

  14. mifi commented on May 20, 2020

    @mifi
    Contributor

    I added a PR to update the docs so we don't have more developers going into this trap.

  15. semireg commented on May 20, 2020

    @semireg

    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.

      log.info(`isWindowsStoreForced process.env.FORCE_MS_STORE: ${process.env.FORCE_MS_STORE}`);
    

    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).

  16. semireg commented on May 20, 2020

    @semireg

    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.

    2020-05-20 at 8 06 AM

    const openLogsDir = () => {
      const logPath = log.transports.file.findLogPath();
      if (logPath == null) {
        return;
      }
      const logDir = path.dirname(logPath);
      log.info(`logDir: ${logDir}`);
      shell.openExternal(`file://${logDir}`);
    };
    

    To me, this is indicative of windowsStore being set wrong.

  17. semireg commented on May 20, 2020

    @semireg

    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.

    1. A recent change in my webpack config was preventing the most recent build of main.prod.js from being bundled into my app.

    2. 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 😞

  18. self-assigned this
    on May 26, 2020
  19. zcbenz commented on May 26, 2020

    @zcbenz
    Contributor
  20. zcbenz commented on May 26, 2020

    @zcbenz
    Contributor

    I'm trying to reproduce this issue but it seems that process.windowsStore works correctly with following steps:

    1. Download a win-x64 release from https://github.com/electron/electron/releases
    2. Unzip it to /electron
    3. Put the files of https://gist.github.com/zcbenz/d0b709d36e1f1006f2da2cfa59491490 under /electron/resources/app.
    4. Run electron-windows-store --input-directory electron --output-directory out --package-version 1.0.0.0 --package-name electron
    5. Install out/electron.appx and run.

    Can anyone try the steps above and see if you still see the problem?

  21. mahnunchik commented on May 26, 2020

    @mahnunchik
    Contributor

    @zcbenz @semireg if I understood correctly this happens with the Appx installed from Windows Store.

  22. zcbenz commented on May 26, 2020

    @zcbenz
    Contributor

    @mahnunchik Do you mean it only happens when the app is submitted to Windows Store?

  23. gaodeng commented on May 26, 2020

    @gaodeng

    @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。

  24. zcbenz commented on May 27, 2020

    @zcbenz
    Contributor

    @gaodeng Thanks for the information, I'm able to reproduce with 8.x, it seems that 9.x is not affected by the bug.

  25. 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
  26. 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
  27. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions