aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-02-11 03:46:13 +0800
committerkumavis <aaron@kumavis.me>2016-02-11 03:46:13 +0800
commit066996396ff0ec6a9f6724e1f6469a0bc67a07ca (patch)
tree5c9e34bd1fe94ffcd2c96b2c288b879258f22489 /app/scripts
parentebf60843fabd743cbf821611fc9343e1d4a323b7 (diff)
downloadtangerine-wallet-browser-066996396ff0ec6a9f6724e1f6469a0bc67a07ca.tar.gz
tangerine-wallet-browser-066996396ff0ec6a9f6724e1f6469a0bc67a07ca.tar.zst
tangerine-wallet-browser-066996396ff0ec6a9f6724e1f6469a0bc67a07ca.zip
context wiring - handle and log errors
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/background.js6
-rw-r--r--app/scripts/contentscript.js6
-rw-r--r--app/scripts/inpage.js3
-rw-r--r--app/scripts/lib/port-stream.js9
4 files changed, 20 insertions, 4 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 6d9f4865d..0276124cc 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.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)
- remotePort.postMessage(response)
+ try {
+ remotePort.postMessage(response)
+ } catch (_) {
+ // port disconnected
+ }
})
}
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js
index 1b0de3375..105f24988 100644
--- a/app/scripts/contentscript.js
+++ b/app/scripts/contentscript.js
@@ -19,4 +19,8 @@ var pluginStream = new PortStream(pluginPort)
// forward communication across
pageStream.pipe(pluginStream)
-pluginStream.pipe(pageStream) \ No newline at end of file
+pluginStream.pipe(pageStream)
+
+// log errors
+pageStream.on('error', console.error.bind(console))
+pluginStream.on('error', console.error.bind(console)) \ No newline at end of file
diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js
index 6bf75084c..001d9f4f9 100644
--- a/app/scripts/inpage.js
+++ b/app/scripts/inpage.js
@@ -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
diff --git a/app/scripts/lib/port-stream.js b/app/scripts/lib/port-stream.js
index 7f3e8072e..8ff77ec4e 100644
--- a/app/scripts/lib/port-stream.js
+++ b/app/scripts/lib/port-stream.js
@@ -37,8 +37,13 @@ PortDuplexStream.prototype._read = noop
PortDuplexStream.prototype._write = function(msg, encoding, cb){
// console.log('PortDuplexStream - sent message', msg)
- this._port.postMessage(msg)
- cb()
+ try {
+ this._port.postMessage(msg)
+ cb()
+ } catch(err){
+ // this.emit('error', err)
+ cb(new Error('PortDuplexStream - disconnected'))
+ }
}
// util