Ferdium fails to request permissions on Mac due to missing .js
extension in dynamic import
#1755
Closed
2 tasks done
Labels
bug 🪲
Something isn't working
Avoid duplicates
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 permissions
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 themacOSPermissions
module.Steps to reproduce
ERR_MODULE_NOT_FOUND
error for themacOSPermissions
moduleDebug link
No response
Screenshots
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!
The text was updated successfully, but these errors were encountered: