Hey! Thanks for your work on Ferdi, love it so far. I've encountered a bug with Fastmail today, and I believe it's connected with Dark Reader.
Describe the bug
When adding Fastmail service, it won't load - JS and other assets load fine, but something prevents the page from loading completely. This something is CORS and DarkReader related - see console logs. Nothing noteworthy in Network tab.
I've tried disabling Dark Mode completely, but it looks like the offending JS is still injected in page.
To Reproduce
Steps to reproduce the behavior:
JS Console
/usr/lib/ferdi/resources/app.asar/webview/spellchecker.js:1 Error: document.body is null, if you're calling this in a preload script you need to wrap it in a setTimeout
at SpellCheckHandler.attachToInput (/usr/lib/ferdi/resources/app.asar/node_modules/electron-spellchecker/src/spell-check-handler.js:214)
at initialize (/usr/lib/ferdi/resources/app.asar/webview/spellchecker.js:1)
at _temp.initialize (/usr/lib/ferdi/resources/app.asar/webview/recipe.js:1)
at new _temp (/usr/lib/ferdi/resources/app.asar/webview/recipe.js:1)
at Object.<anonymous> (/usr/lib/ferdi/resources/app.asar/webview/recipe.js:1)
at Object.<anonymous> (/usr/lib/ferdi/resources/app.asar/webview/recipe.js:2)
at Module._compile (internal/modules/cjs/loader.js:786)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:798)
at Module.load (internal/modules/cjs/loader.js:645)
at Function.Module._load (internal/modules/cjs/loader.js:560)
initialize @ /usr/lib/ferdi/resources/app.asar/webview/spellchecker.js:1
/usr/lib/ferdi/resources/app.asar/webview/recipe.js:1 Set theme to: Light
/usr/lib/ferdi/resources/app.asar/webview/recipe.js:1 DarkMode disabled - removing remaining styles
/usr/lib/ferdi/resources/app.asar/webview/recipe.js:1 Removing DarkReader
/usr/lib/ferdi/resources/app.asar/webview/spellchecker.js:1 Dictionary is already used en-us
switchDict @ /usr/lib/ferdi/resources/app.asar/webview/spellchecker.js:1
/usr/lib/ferdi/resources/app.asar/webview/recipe.js:1 Set theme to: Dark
/usr/lib/ferdi/resources/app.asar/webview/recipe.js:1 darkmode.css exists? No
/usr/lib/ferdi/resources/app.asar/webview/recipe.js:1 Injecting DarkReader
/usr/lib/ferdi/resources/app.asar/webview/spellchecker.js:1 Dictionary is already used en-us
switchDict @ /usr/lib/ferdi/resources/app.asar/webview/spellchecker.js:1
/usr/lib/ferdi/resources/app.asar/webview/recipe.js:1 Set theme to: Dark
/usr/lib/ferdi/resources/app.asar/webview/recipe.js:1 darkmode.css exists? No
/usr/lib/ferdi/resources/app.asar/node_modules/darkreader/darkreader.js:82 Uncaught Error: Access to some of your resources was blocked by cross-origin policy
at Object.throwCORSError [as sendMessage] (/usr/lib/ferdi/resources/app.asar/node_modules/darkreader/darkreader.js:82)
at Object.t.getMessagePort (base-raw.js:24911)
at Object.t.getPortSingleton_ (base-raw.js:25265)
at Object.t.getApiVersion (base-raw.js:25405)
at eval (base-raw.js:25478)
at eval (base-raw.js:25454)
at eval (<anonymous>)
at bootstrap-raw.js:93
Expected behavior
Fastmail loaded :)
Desktop (please complete the following information):
The problem seems to be that DarkReader tries to use the chrome message API even though it isn't inside a context that would allow this.
After some testing it seems like the solution was to simply add a mock function for sending messages but that doesn't actually do anything. FastMail now loads again and it even works with DarkReader darkmode.
Most helpful comment
The problem seems to be that DarkReader tries to use the chrome message API even though it isn't inside a context that would allow this.
After some testing it seems like the solution was to simply add a mock function for sending messages but that doesn't actually do anything. FastMail now loads again and it even works with DarkReader darkmode.