self.Symbol.for is undefined in a webextension in FF
kirlat opened this issue · comments
We're using a system-observable
inside a content script of a webextension (as a dependency of the Apollo client). In the webextension, root
is self
so it uses a self.Symbol
as a Symbol object (https://github.com/benlesh/symbol-observable/blob/master/es/ponyfill.js#L3). Unfortunately, we've discovered that in content scripts of a webestension in Firefox (as of version 83) the self.Symbol.for
is undefined, even though self.Symbol
is a valid object with the for
property available.
As a result, result = Symbol.for('https://github.com/benlesh/symbol-observable')
(https://github.com/benlesh/symbol-observable/blob/master/es/ponyfill.js#L13) throws an unhandled error (Symbol.for
is undefined) and the content script loading fails.
Even thought this probably is an issue on the Firefox side (it works in Chrome perfectly), I think it might be worth adding a check for Symbol.for
before calling it. That would help to avoid the problem described above now and in the future, in various environments.
What do you think? I can create a PR if you don't mind.