MetaMask / extension-provider

A module for allowing a WebExtension to access the web3 provider from an installed MetaMask instance
MIT License
68 stars 28 forks source link

Extension streams attempt connection to every site #50

Closed c1im4cu5 closed 4 months ago

c1im4cu5 commented 4 months ago

Import note before we begin, as long as an app/site the user visits possesses Metamask capabilities, the following errors do NOT appear. I have re-worked the configuration to properly import the stream.

Stack Trace dist/contentScript.bundle.js:1223 (_write) dist/contentScript.bundle.js:3188 (doWrite) dist/contentScript.bundle.js:3177 (writeOrBuffer) dist/contentScript.bundle.js:3094 (Writable.write) dist/contentScript.bundle.js:24986 (ondata) dist/contentScript.bundle.js:16447 (emit) dist/contentScript.bundle.js:24602 (addChunk) dist/contentScript.bundle.js:24579 (readableAddChunk) dist/contentScript.bundle.js:24525 (Readable.push) dist/contentScript.bundle.js:20893 (_onMessage) dist/contentScript.bundle.js:20875 (anonymous function)

Each error = ObjectMultiplex - orphaned data for stream "publicConfig"

The errors can be traced back to the stream-browserify node_module.

I had to rework the import process since some libraries weren't native to the browser. I installed the readable-stream library and realigned the reference. Ex: Stream.Readable = require('../readable-stream/lib/_stream_readable.js');

When my extension runs on a Metamask supported site, the errors are not present; however, I do not want my extrension querying each site the user visits for Metamask capabilities. I have a button on the extension that will perform the task. I just cannot stop readable-stream from checking every site for Metamask.

Any ideas on a resolution? I don't really need help with the error message. It appears to be a by-product of constantly checking for a connection to Metamask with each new site the user visits. The errors repeat until a site is reached that possesses the connection.

c1im4cu5 commented 4 months ago

I had been implementing the function at the bottom of my contentScript.js file; which was causing the injection issue.