ripple-unmaintained / ilp-plugin-xrp-escrow

Other
6 stars 8 forks source link

[intermittent] cannot read Memo of undefined #19

Open michielbdejong opened 7 years ago

michielbdejong commented 7 years ago

Saw this in my logs; tried to reproduce it but it seems to be intermittent:

VirtualPeer calls sendTransfer! { id: '1001a4f4-f983-4970-9394-bb1ef352ea60',
  from: 'test.crypto.xrp.rrhnXcox5bEmZfJCHzPxajUtwdt772zrCW',
  to: 'test.crypto.xrp.rB1vPd6fnPZQUHmnxexfzXsUPdKKjfTQxQ',
  ledger: 'test.crypto.xrp.',
  amount: '1',
  ilp: 'AUAAAAAAAAAAATV0ZXN0LmNyeXB0by54cnAuckIxdlBkNmZuUFpRVUhtbnhleGZ6WHNVUGRLS2pmVFF4US5oaQAA',
  noteToSelf: {},
  executionCondition: 'slJDyGSrPBUR0GYjjovpjx9Ty5RDh7L8ZrbaxO6Bx9g=',
  expiresAt: '2017-09-13T09:41:18.296Z',
  custom: {} }
handleTransfer! <Buffer b2 52 43 c8 64 ab 3c 15 11 d0 66 23 8e 8b e9 8f 1f 53 cb 94 43 87 b2 fc 66 b6 da c4 ee 81 c7 d8>
handleTransfer came in index! { from: 'test.crypto.xrp.rrhnXcox5bEmZfJCHzPxajUtwdt772zrCW',
  expiresAt: 2017-09-13T09:41:18.000Z,
  amount: 1,
  executionCondition: <Buffer b2 52 43 c8 64 ab 3c 15 11 d0 66 23 8e 8b e9 8f 1f 53 cb 94 43 87 b2 fc 66 b6 da c4 ee 81 c7 d8> } <Buffer 01 40 00 00 00 00 00 00 00 01 35 74 65 73 74 2e 63 72 79 70 74 6f 2e 78 72 70 2e 72 42 31 76 50 64 36 66 6e 50 5a 51 55 48 6d 6e 78 65 78 66 7a 58 73 ... >
1 transfers took 13977ms, that is 0.07154611146884167 payments per second.
/Users/michiel/gh/michielbdejong/ilp-node/node_modules/ilp-plugin-xrp-escrow/src/translate.js:57
  const memos = parseMemos(cached.Memos)
                                 ^

TypeError: Cannot read property 'Memos' of undefined
    at escrowToTransfer (/Users/michiel/gh/michielbdejong/ilp-node/node_modules/ilp-plugin-xrp-escrow/src/translate.js:57:34)
    at Object.escrowCancelToTransfer (/Users/michiel/gh/michielbdejong/ilp-node/node_modules/ilp-plugin-xrp-escrow/src/translate.js:88:10)
    at PluginXrpEscrow._handleTransaction (/Users/michiel/gh/michielbdejong/ilp-node/node_modules/ilp-plugin-xrp-escrow/src/plugin.js:394:34)
    at RestrictedConnection._api.connection.on (/Users/michiel/gh/michielbdejong/ilp-node/node_modules/ilp-plugin-xrp-escrow/src/plugin.js:82:12)
    at emitOne (events.js:96:13)
    at RestrictedConnection.emit (events.js:191:7)
    at RestrictedConnection._onMessage (/Users/michiel/gh/michielbdejong/ilp-node/node_modules/ripple-lib/dist/npm/common/connection.js:129:17)
    at emitTwo (events.js:106:13)
    at WebSocket.emit (events.js:194:7)
    at Receiver.ontext (/Users/michiel/gh/michielbdejong/ilp-node/node_modules/ripple-lib/node_modules/ws/lib/WebSocket.js:841:10)
michielbdejong commented 6 years ago

Ran into this again today:


[michiel@mbp ~/gh/interledger/tutorials/streaming-payments (mj-update-first-four)]$ node streaming-client1.js
/Users/michiel/gh/interledger/tutorials/node_modules/ilp-plugin-xrp-escrow/src/translate.js:57
  const memos = parseMemos(cached.Memos)
                                 ^

TypeError: Cannot read property 'Memos' of undefined
    at escrowToTransfer (/Users/michiel/gh/interledger/tutorials/node_modules/ilp-plugin-xrp-escrow/src/translate.js:57:34)
    at Object.escrowFinishToTransfer (/Users/michiel/gh/interledger/tutorials/node_modules/ilp-plugin-xrp-escrow/src/translate.js:84:10)
    at PluginXrpEscrow._handleTransaction (/Users/michiel/gh/interledger/tutorials/node_modules/ilp-plugin-xrp-escrow/src/plugin.js:369:34)
    at RestrictedConnection._api.connection.on (/Users/michiel/gh/interledger/tutorials/node_modules/ilp-plugin-xrp-escrow/src/plugin.js:83:12)
    at emitOne (events.js:96:13)
    at RestrictedConnection.emit (events.js:191:7)
    at RestrictedConnection._onMessage (/Users/michiel/gh/interledger/tutorials/node_modules/ripple-lib/dist/npm/common/connection.js:129:17)
    at emitTwo (events.js:106:13)
    at WebSocket.emit (events.js:194:7)
    at Receiver.ontext (/Users/michiel/gh/interledger/tutorials/node_modules/ripple-lib/node_modules/ws/lib/WebSocket.js:841:10)
sharafian commented 6 years ago

I think I've seen this happen once or twice when an account was notified of a payment made by a non-plugin source. Or it may be because you're receiving notifications for another account (i.e. two plugins are listening on the same account and one got a fulfill for a transfer they didn't hear about). I think the fix is just to add a check to see if we have the details cached and then ignore it if we don't