extension-port-stream
extension-port-stream copied to clipboard
A module for creating a node style stream over a WebExtension port object.
fixes https://github.com/MetaMask/metamask-extension/issues/14987 fixes #22 runtime.lastError needs to be checked when doing callback-based async things: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/lastError https://developer.chrome.com/docs/extensions/reference/runtime/ By just reading the value, the error message goes away. In the case of...
Fixes #22 `webextension-polyfill-ts` doesn't include the firefox variant with the error appended to it and other typescript woes

https://github.com/MetaMask/extension-port-stream/blob/6e32c73a5c7b66ede01fad9d8dc83e9991eed49f/src/index.ts#L14-L15 ``` Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist. ``` needs to be handled in this way per https://stackoverflow.com/a/56787332 ```js chrome.runtime.sendMessage('ping', response => { if(chrome.runtime.lastError) {...