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

Ferdium fails to request permissions on Mac due to missing .js extension in dynamic import #1755

Closed
2 tasks done
bdteo opened this issue May 10, 2024 · 2 comments · Fixed by #1760
Closed
2 tasks done
Labels
bug 🪲 Something isn't working

Comments

@bdteo
Copy link

bdteo commented May 10, 2024

Avoid duplicates

  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issues tracker for a bug report similar to mine, in vain

Ferdium Version

6.7.4-nightly.8

What Operating System are you using?

macOS

Operating System Version

macOS Sonoma 14.4.1, Build 23E224

What arch are you using?

arm64 (including Apple Silicon)

Last Known Working Ferdium version

No response

Expected Behavior

Ferdium should properly request necessary permissions on macOS, such as access to microphone, camera, file access, etc. This should happen on first launch and allow the user to grant or deny these permi​ssions

Actual Behavior

Ferdium silently fails to request any permissions on macOS. Features that require permissions, such as audio/video calls, do not function properly. No visible errors are shown to the user, but the stderr output in the terminal shows an ERR_MODULE_NOT_FOUND error for the macOSPermissions module.

Steps to reproduce

  1. Launch Ferdium from the terminal on macOS
  2. Watch the stderr output in the terminal
  3. Observe the ERR_MODULE_NOT_FOUND error for the macOSPermissions module
  4. Try using a feature that requires permissions (e.g., audio/video call) and notice it doesn't work

Debug link

No response

Screenshots

Screenshot 2024-05-10 at 8 09 35

Additional information

I noticed that the Ferdium desktop app on macOS is not properly requesting necessary permissions, causing some features to silently fail. The app launches and appears to work, but watching the stderr output in the terminal reveals the following error:

(node:9385) UnhandledPromiseRejectionWarning: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Applications/Ferdium.app/Contents/Resources/app.asar/electron/macOSPermissions' imported from /Applications/Ferdium.app/Contents/Resources/app.asar/index.js ​

After investigating, it appears the problem is caused by a dynamic import statement in index.ts that is missing the .js file extension:

ts import('./electron/macOSPermissions').then(macOSPermissions => { const { askFormacOSPermissions } = macOSPermissions; setTimeout(() => askFormacOSPermissions(mainWindow!), ms('30s')); }); ​

The file macOSPermissions.js does exist in the /electron directory inside the app.asar archive. However, omitting the .js extension in the dynamic import path seems to prevent it from being resolved correctly at runtime, causing the permissions flow to never be triggered.


I tried adding the .js extension to the import statement locally and re-packed the asar archive, which allowed Ferdium to successfully request permissions on launch.

I believe this is likely an oversight/mistake in the code rather than an intentional omission. While Node.js module resolution often allows leaving off the .js by default, this behavior does not always carry over to dynamic ES module imports, especially in the context of Electron and packaged asar files.

Please review this issue when you have a chance. I would recommend updating the dynamic import to include the explicit .js extension:

ts import('./electron/macOSPermissions.js').then(macOSPermissions => { ​


Note that I am not providing a pull request at this time, as I am not entirely certain about the full fix and all the internals of Ferdium, including the intentions behind this particular code. I wanted to raise the issue for visibility and discussion first.

Let me know if you need any other info or have questions!

@bdteo bdteo added the bug 🪲 Something isn't working label May 10, 2024
@vraravam
Copy link
Contributor

thanks for the very detailed analysis and description @bdteo . We will take a look at this shortly and come back with a resolution/fix.

@vraravam
Copy link
Contributor

please test this out in the next nightly (12) which will be released in another 16+ hours

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants