aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-01-27 12:18:28 +0800
committerkumavis <aaron@kumavis.me>2017-01-27 12:18:28 +0800
commitfc3a53ec7b2af538d5e9748173fb11b5a09a4e84 (patch)
tree380ec77e2635f17ede85eaa5ad9aab00a7ec83a7 /app
parent2f79781ab9fbdde018fc921da9be0b3411ed8cad (diff)
downloadtangerine-wallet-browser-fc3a53ec7b2af538d5e9748173fb11b5a09a4e84.tar
tangerine-wallet-browser-fc3a53ec7b2af538d5e9748173fb11b5a09a4e84.tar.gz
tangerine-wallet-browser-fc3a53ec7b2af538d5e9748173fb11b5a09a4e84.tar.bz2
tangerine-wallet-browser-fc3a53ec7b2af538d5e9748173fb11b5a09a4e84.tar.lz
tangerine-wallet-browser-fc3a53ec7b2af538d5e9748173fb11b5a09a4e84.tar.xz
tangerine-wallet-browser-fc3a53ec7b2af538d5e9748173fb11b5a09a4e84.tar.zst
tangerine-wallet-browser-fc3a53ec7b2af538d5e9748173fb11b5a09a4e84.zip
background - stream disconnection fix
Diffstat (limited to 'app')
-rw-r--r--app/scripts/background.js7
-rw-r--r--app/scripts/lib/stream-utils.js9
2 files changed, 8 insertions, 8 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 18882e5d5..744a0caee 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -122,17 +122,16 @@ function setupController (initState) {
// remote features
//
- function setupControllerConnection (stream) {
- controller.stream = stream
+ function setupControllerConnection (outStream) {
var api = controller.getApi()
var dnode = Dnode(api)
- stream.pipe(dnode).pipe(stream)
+ outStream.pipe(dnode).pipe(outStream)
dnode.on('remote', (remote) => {
// push updates to popup
var sendUpdate = remote.sendUpdate.bind(remote)
controller.on('update', sendUpdate)
// teardown on disconnect
- eos(stream, () => {
+ eos(outStream, () => {
controller.removeListener('update', sendUpdate)
popupIsOpen = false
})
diff --git a/app/scripts/lib/stream-utils.js b/app/scripts/lib/stream-utils.js
index 1b7b89d14..ba79990cc 100644
--- a/app/scripts/lib/stream-utils.js
+++ b/app/scripts/lib/stream-utils.js
@@ -1,4 +1,5 @@
const Through = require('through2')
+const endOfStream = require('end-of-stream')
const ObjectMultiplex = require('./obj-multiplex')
module.exports = {
@@ -24,11 +25,11 @@ function jsonStringifyStream () {
function setupMultiplex (connectionStream) {
var mx = ObjectMultiplex()
connectionStream.pipe(mx).pipe(connectionStream)
- mx.on('error', function (err) {
- console.error(err)
+ endOfStream(mx, function (err) {
+ if (err) console.error(err)
})
- connectionStream.on('error', function (err) {
- console.error(err)
+ endOfStream(connectionStream, function (err) {
+ if (err) console.error(err)
mx.destroy()
})
return mx