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

Fix filter polling leak #1474

Merged
merged 7 commits into from
May 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Current Master

- Fix bug where website filters would pile up and not deallocate when leaving a site.

## 3.6.5 2017-5-17

- Fix bug where edited gas parameters would not take effect.
Expand Down
22 changes: 17 additions & 5 deletions app/scripts/lib/inpage-provider.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const pipe = require('pump')
const StreamProvider = require('web3-stream-provider')
const ProviderEngine = require('web3-provider-engine')
const FilterSubprovider = require('web3-provider-engine/subproviders/filters')
const StreamSubprovider = require('web3-provider-engine/subproviders/stream')
const LocalStorageStore = require('obs-store')
const ObjectMultiplex = require('./obj-multiplex')
const createRandomId = require('./random-id')
Expand Down Expand Up @@ -27,14 +29,24 @@ function MetamaskInpageProvider (connectionStream) {
)

// connect to async provider
const asyncProvider = self.asyncProvider = new StreamProvider()
const engine = new ProviderEngine()

const filterSubprovider = new FilterSubprovider()
engine.addProvider(filterSubprovider)

const streamSubprovider = new StreamSubprovider()
engine.addProvider(streamSubprovider)

pipe(
asyncProvider,
streamSubprovider,
multiStream.createStream('provider'),
asyncProvider,
streamSubprovider,
(err) => logStreamDisconnectWarning('MetaMask RpcProvider', err)
)

// start polling
engine.start()

self.idMap = {}
// handle sendAsync requests via asyncProvider
self.sendAsync = function (payload, cb) {
Expand All @@ -46,7 +58,7 @@ function MetamaskInpageProvider (connectionStream) {
return message
})
// forward to asyncProvider
asyncProvider.sendAsync(request, function (err, res) {
engine.sendAsync(request, function (err, res) {
if (err) return cb(err)
// transform messages to original ids
eachJsonMessage(res, (message) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"valid-url": "^1.0.9",
"vreme": "^3.0.2",
"web3": "0.18.2",
"web3-provider-engine": "^12.0.6",
"web3-provider-engine": "^12.1.0",
"web3-stream-provider": "^2.0.6",
"xtend": "^4.0.1"
},
Expand Down