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

Set process.resourcesPath to quiet electron-updater during Linux tests #3097

Merged
merged 2 commits into from
Jun 14, 2024

Conversation

philrz
Copy link
Contributor

@philrz philrz commented Jun 14, 2024

Since the merge of #3084, I've noticed that in the "Zui CI" Actions workflow on the Ubuntu runner there's warnings in the yarn test step, such as those in this recent run:

PASS apps/zui/src/electron/start.test.ts
  ● Console

    console.warn
      Unable to detect 'package-type' for autoUpdater (beta rpm/deb support). If you'd like to expand support, please consider contributing to electron-builder The "path" argument must be of type string. Received undefined

       7 | import pkg from "src/electron/pkg"
       8 |
    >  9 | autoUpdater.autoDownload = false
         |            ^
      10 | autoUpdater.autoInstallOnAppQuit = false
      11 | autoUpdater.forceDevUpdateConfig = true
      12 |

      at doLoadAutoUpdater (../../node_modules/electron-updater/src/main.ts:52:15)
      at Object.get [as autoUpdater] (../../node_modules/electron-updater/src/main.ts:64:28)
      at Object.<anonymous> (src/domain/updates/linux-updater.ts:9:12)
      at Object.<anonymous> (src/domain/updates/updater.ts:2:45)
      at Object.<anonymous> (src/domain/updates/operations.ts:2:34)
      at Object.<anonymous> (src/initializers/auto-update.ts:5:52)
      at Object.<anonymous> (src/initializers/index.ts:1:23)
      at Object.<anonymous> (src/electron/run-main/run-initializers.ts:3:25)
      at Object.<anonymous> (src/electron/run-main/boot.ts:4:51)
      at Object.<anonymous> (src/electron/run-main/run-main.ts:4:28)
      at Object.<anonymous> (src/electron/start.test.ts:5:41)

I dug into this and found the root cause to be this line from the "beta" support for Linux auto-update added in electron-userland/electron-builder#7060. It looks for this package-type file that normally appears in a location like /opt/Zui/resources/package-type when running a packaged version of the app, but the process.resourcesPath that's used to build that path has been undefined when running our Jest tests. Just the act of importing autoUpdater and making those config settings shown above is enough to trigger this code that looks for the package-type file, hence why it it lands in the catch block and prints the warning.

A clean fix might be to make electron-updater smarter about bailing early when process.resourcesPath is undefined. However, I had challenges when trying to test with a modified electron-updater in a fork repo, so @jameskerr suggested we just make it happy by supplying this dummy value so electron-updater will bail cleanly when it finds the path does not exist on the next line.

@philrz philrz changed the title Set process.resourcesPath to quiet electron-updater during tests on Linux Set process.resourcesPath to quiet electron-updater during Linux tests Jun 14, 2024
@philrz philrz self-assigned this Jun 14, 2024
@philrz philrz requested a review from jameskerr June 14, 2024 23:24
Copy link
Member

@jameskerr jameskerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks looks great

@philrz philrz merged commit 942b10f into main Jun 14, 2024
4 checks passed
@philrz philrz deleted the electron-updater-linux-tests-fix branch June 14, 2024 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants