interledger-deprecated / ilp-plugin-bells

ILP Ledger plugin for five-bells-ledger
Other
4 stars 8 forks source link

disconnect takes a full 60 seconds #152

Closed michielbdejong closed 7 years ago

michielbdejong commented 7 years ago

Save this as test.js:

// const log = require('why-is-node-running') // should be your first require
const FiveBellsLedgerPlugin = require('ilp-plugin-bells')

let plugin = new FiveBellsLedgerPlugin({
  account: 'https://red.ilpdemo.org/ledger/accounts/alice',
  password: 'alice'
});

plugin.connect().then(() => {
  console.log('connected!')
  return plugin.disconnect()
}).then(() => {
  console.log('disconnected, expecting process to exit now...')
  plugin = null
  // log() // logs out active handles that are keeping node running
})

Now run (the --expose-internals is needed because of https://github.com/mafintosh/why-is-node-running/issues/7):

npm install ilp-plugin-bells why-is-node-running
node --expose-internals test.js

You will see the process hangs after the 'disconnected, expecting process to exit now...' statement. Unfortunately, if you uncomment the first line, the process crashes with an error in net.js, so I haven't been able yet to acually use why-is-node-running to find out why node is running..

@sentientwaffle any idea why the node process keeps running even after you call plugin.disconnect()? Seems to me it's probably related to the whole WebSocket reconnect logic, which is now properly complex in https://github.com/interledgerjs/ilp-plugin-bells/blob/master/src/lib/plugin.js#L211-L330

michielbdejong commented 7 years ago

Correction, the process hangs for one minute, then exits (I guess the 3 seconds is the time it takes to connect, then disconnect takes 60 seconds?):

time node test.js
connected!
disconnected, expecting process to exit now...

real    1m3.093s
user    0m0.603s
sys 0m0.059s
michielbdejong commented 7 years ago

confirmed that it's fixed in that branch.