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

Work around firefox webextensions bug #249

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DCNick3
Copy link

@DCNick3 DCNick3 commented Aug 29, 2022

Importing gloo_timers in firefox webextension's content script results in an error: LinkError: import object field '__wbg_clearTimeout_65417660fe82f08d' is not a Function

It actually seems to be a firefox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1787770

This can simply be worked around by refering to timer functions using window object (setInterval -> window.setInterval) which this PR does. I do not think this would impact users outside of webextensions in any way, as window.setInterval and setInterval are the same functions in usual context (but apparently not in content scripts...)

@DCNick3
Copy link
Author

DCNick3 commented Aug 29, 2022

Well, looks like this work around is not good enough. While the wasm module does instantiate fine, it still raises an error TypeError: 'clearTimeout' called on an object that does not implement interface Window. when the function is actually invoked.

@DCNick3
Copy link
Author

DCNick3 commented Aug 29, 2022

Now this should work. Instead of using window object to refer to the function I make wasm-bindgen generate a wrapper around the desired function by marking it with catch. This way wasm module does not error out on instantiation and is actually able to use those APIs

@ranile
Copy link
Collaborator

ranile commented Sep 16, 2022

It seems as a fix for the Firefox bug is underway. I would say we shouldn't merge this and let Firefox handle it.

kmusick added a commit to kmusick/uuid that referenced this pull request Jun 21, 2023
…bAssembly.Instance(): Import uuid-rs#9 module="./index_bg.js" function="__wbg_now_dc6f7ce2227b5592" error: function import requires a callable"

Similar issue: rustwasm/gloo#249
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