context wiring - handle and log errors

feature/default_network_editable
kumavis 9 years ago
parent ebf60843fa
commit 066996396f
  1. 4
      app/scripts/background.js
  2. 4
      app/scripts/contentscript.js
  3. 3
      app/scripts/inpage.js
  4. 5
      app/scripts/lib/port-stream.js

@ -76,7 +76,11 @@ function onRpcRequest(remotePort, payload){
zeroClient.sendAsync(payload, function onPayloadHandled(err, response){
if (err) throw err
// console.log('MetaMaskPlugin - RPC complete:', payload, '->', response)
try {
remotePort.postMessage(response)
} catch (_) {
// port disconnected
}
})
}

@ -20,3 +20,7 @@ var pluginStream = new PortStream(pluginPort)
// forward communication across
pageStream.pipe(pluginStream)
pluginStream.pipe(pageStream)
// log errors
pageStream.on('error', console.error.bind(console))
pluginStream.on('error', console.error.bind(console))

@ -12,6 +12,9 @@ var pluginStream = new LocalMessageDuplexStream({
var remoteProvider = new StreamProvider()
remoteProvider.pipe(pluginStream).pipe(remoteProvider)
pluginStream.on('error', console.error.bind(console))
remoteProvider.on('error', console.error.bind(console))
// handle synchronous methods remotely
// handle accounts cache

@ -37,8 +37,13 @@ PortDuplexStream.prototype._read = noop
PortDuplexStream.prototype._write = function(msg, encoding, cb){
// console.log('PortDuplexStream - sent message', msg)
try {
this._port.postMessage(msg)
cb()
} catch(err){
// this.emit('error', err)
cb(new Error('PortDuplexStream - disconnected'))
}
}
// util

Loading…
Cancel
Save