Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Unexpected token j in JSON at position 1464 #12

Open
fmtpay opened this issue Nov 29, 2018 · 0 comments
Open

SyntaxError: Unexpected token j in JSON at position 1464 #12

fmtpay opened this issue Nov 29, 2018 · 0 comments

Comments

@fmtpay
Copy link

fmtpay commented Nov 29, 2018

Hey,

I am doing some stress testing and I have ~1000 requests per minute. At some point the messages are not built correctly and on subscribe/connect I receive the following error:

`at TCP._handle.close [as _onclose] (net.js:567:12)
Error: close connect
at Object.keys.forEach (/home/florin/projects/wallet-api/electrum-rest/node_modules/electrum-client-wrapper/lib/client.js:82:46)
at Array.forEach ()
at ElectrumClient.onClose (/home/florin/projects/wallet-api/electrum-rest/node_modules/electrum-client-wrapper/lib/client.js:81:50)
at ElectrumClient.onClose (/home/florin/projects/wallet-api/electrum-rest/node_modules/electrum-client-wrapper/lib/electrum_client.js:7:15)
at Socket.conn.on (/home/florin/projects/wallet-api/electrum-rest/node_modules/electrum-client-wrapper/lib/init_socket.js:34:14)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at TCP._handle.close [as _onclose] (net.js:567:12)
undefined:1
{"jsonrpc": "2.0", "result": {"hex": "01000000fbc7fb5b01d7e2dd283eb76598bcc0ace50989c089b202721d5a0b29ce666c6e508206c21c000000006b483045022100ebc3beff03ba9203c8dce50ba41e6f755098514cfa5f5c5282966a664986491f0220614c28f89b15cd4c77c20d32c97ad8d42971536f3341a7c407a2c92ce65fa3ff012102fa6c3064d018ae8bf566778425d7c869c6b9e40664565b9ebfbb0f4533fcc70affffffff0280969800000000001976a914fff8cd2c57f44866fb743363aa1b743fd231586b88ac700c023b000000001976a9147f53a24a39584eece254b1ed6677fcee77a4620488ac00000000", "txid": "deade9801d431672fac54dfbb6deea267af41b18f5a685835b25fa28b507db7c", "version": 1, "time": 1543238144, "locktime": 0, "vin": [{"txid": "1cc20682506e6c66ce290b5a1d7202b289c08909e5acc0bc9865b73e28dde2d7", "vout": 0, "scriptSig": {"asm": "3045022100ebc3beff03ba9203c8dce50ba41e6f755098514cfa5f5c5282966a664986491f0220614c28f89b15cd4c77c20d32c97ad8d42971536f3341a7c407a2c92ce65fa3ff01 02fa6c3064d018ae8bf566778425d7c869c6b9e40664565b9ebfbb0f4533fcc70a", "hex": "483045022100ebc3beff03ba9203c8dce50ba41e6f75

SyntaxError: Unexpected token j in JSON at position 1464
at JSON.parse ()
at ElectrumClient.onMessage (/home/florin/projects/wallet-api/electrum-rest/node_modules/electrum-client-wrapper/lib/client.js:65:26)
at Client.mp.util.MessageParser (/home/florin/projects/wallet-api/electrum-rest/node_modules/electrum-client-wrapper/lib/client.js:16:18)
at MessageParser.recursiveParser (/home/florin/projects/wallet-api/electrum-rest/node_modules/electrum-client-wrapper/lib/util.js:26:9)
at MessageParser.run (/home/florin/projects/wallet-api/electrum-rest/node_modules/electrum-client-wrapper/lib/util.js:49:30)
at ElectrumClient.onRecv (/home/florin/projects/wallet-api/electrum-rest/node_modules/electrum-client-wrapper/lib/client.js:88:17)
at Socket.conn.on (/home/florin/projects/wallet-api/electrum-rest/node_modules/electrum-client-wrapper/lib/init_socket.js:45:14)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
`

The json with the issue:
{"jsonrpc": "2.0", "result": {"hex": "01000000d3ebe45b03c4a385bb104b594c70a0899cf025b276e370cacfb{"jsonrpc": "2.0", "result": [{"tx_hash": "1cc20682506e6c66ce290b5a1d7202b289c08909e5acc0bc9865b73e28dde2d7", "height": 419983}, {"tx_hash": "deade9801d431672fac54dfbb6deea267af41b18f5a685835b25fa28b507db7c", "height": 425534}, {"tx_hash": "a459a2ef7c6a0c83ad7f4069150fa7a24ec670e5f80477d3f2efeb16a767ee1d", "height": 425536}, {"tx_hash": "b80d859db0a0d698d71fb360d53375e1a8a35988052dcad4a2d8a84c1b60de43", "height": 425660}, {"tx_hash": "c52d093621b1237b9103fc6562cabf8e9a99867ca9a0480231c9eb0b701fccff", "height": 425719}, {"tx_hash": "553580317e9079891d13ef40b831e2bb483fc8fed429a2dffeff38fbc3a7325c", "height": 425720}, {"tx_hash": "ffe5816615796fa793ab8a7aa298a28a6a30f5a92025fcd433ecd26e43bd5b6e", "height": 425721}, {"tx_hash": "39c161a9065eb22d3e8f193964eda93a95489aeea0f56caf204668726a2f4b23", "height": 425727}, {"tx_hash": "8a11f83970caeb303edc7880dad94c07af734fb83b9e880f691ee0f59788a44c", "height": 425727}, {"tx_hash": "7ba9d3aa133de9cf7216bd1169239308a346df5f99b667eb1ae4dd8eb43050a2", "height": 425727}, {"tx_hash": "33c3dd5b639136dc87b405998fa2ef5ab562bcbad896aeb16d4e0d17fe25eb05", "height": 425727}, {"tx_hash": "47f15b7515c4e9e6e4804c1a86b8bd9e493a08cc0f7abc8ba164161e2f533934", "height": 425729}, {"tx_hash": "5520735f08657ed73e6cea61856cc2cf8a84903e4153b2e27210a39fcea9180d", "height": 425802}, {"tx_hash": "33ab4ff2cc016435433afc88e4cad46bb52d5d9c1108a9ea029dca50ab2739b2", "height": 425803}, {"tx_hash": "3c2ed464410660fffe1188b75c72daae6141b666eae06ffed1c0d00816471b5e", "height": 426740}, {"tx_hash": "52d4c7bc23849093edaa218d5602abd42da3c05be36a952eb2dd371ee8f65f2d", "height": 426740}, {"tx_hash": "529bbd009d9c567a517208192580106790fccdccef07d5b9c5535c5d42cadc21", "height": 426743}, {"tx_hash": "c86b7ee72e2ae818508b764606929e432eef034bdcdd18960833d17a3e5e95b6", "height": 426759}, {"tx_hash": "fca8d3a31a2ba19802d980712c5b5808821d6023f2529534f0ed1b040e970f54", "height": 426806}, {"tx_hash": "3ebf89895dac382248114ca2e9e1e9953f8f0f5d4df40215733bfbd6c3a83d10", "height": 426827}, {"tx_hash": "cdb0d71b9f745029d03101009ecb613f464343e000ab64ea407e19978eb04995", "height": 426827}, {"tx_hash": "27a0be1a30ddaf6a3bc1defff88749877171324b9ccf961936579191cf77d564", "height": 426850}, {"tx_hash": "7ea185ec9a525f836e6ce107ae8f9d7372357e2e72cf1f96196389f70c372cee", "height": 426853}, {"tx_hash": "fd3f18646792283313043911ddc97bdcf19acfa024ce4e9fa8a62fc83e636d59", "height": 426854}, {"tx_hash": "9ec6dc6c497e037aeec164cebfb3d72f58c6c1734a338bf77859a96bcea2ef73", "height": 426857}, {"tx_hash": "f959f63d3736f1b92ab022fa9c7f70c19813fb6141f88879fc9c569a63db6eb6", "height": 426859}, {"tx_hash": "c143dc2bab316e43cd1abfc92759e0988f684e3868054a6d07fc78d45c699953", "height": 426866}, {"tx_hash": "661b6689f087c7ea682249c08593e3b69c84ae80bb9cfecceb983510bbc4cd25", "height": 426869}, {"tx_hash": "30a53c714d312d917b406bf2c2fa6e3d0b92fffb8967da4320a7ba910bc9ccce", "height": 426873}, {"tx_hash": "c3e48d0db92dc62c1c84ec991b48f9988c4424d26022fb57b0795bff990ed2f2", "height": 426875}, {"tx_hash": "dc7f9b95845c9f9c98b289e21d16eb8a83321c629233b37c04a06b72c7f82b62", "height": 426903}, {"tx_hash": "f1f01eec124dec2d23f58d43bb277002554ebae20c03b511f8642c8682451e25", "height": 426907}, {"tx_hash": "196ea936663f135c6d2df1601e40cf7a00b42352619ad89ef9cea357bd9108b1", "height": 426908}, {"tx_hash": "e08ae3835b73bf3e078fa41210c37900141977823b8cd6dbc534618113b32f87", "height": 426936}, {"tx_hash": "5ad24687b35772a3787ddd96901fd7d9871d40f77aba8327bbb4573ba2f6171f", "height": 426940}, {"tx_hash": "041d297a5f656e31099a92c904240ceeb6ca14c2947d4d7adbfea097a4eb38ac", "height": 426950}, {"tx_hash": "167d4670cb90261fef0013a3847bd551221028755130e2afe6db44be65b712a1", "height": 426956}, {"tx_hash": "c4f41f5359469f38e018d037e1bf4018cb2444c2014133696c6201f3709c1eb7", "height": 426964}, {"tx_hash": "475a77663cea647cc7645d68dc81e6f433ecc58e104fcd2458e65768c443e5d8", "height": 426969}, {"tx_hash": "65c9c47bedbaefbd15634543acef3bbbb4367641498b1e5982d56ce574b5d2b1", "height": 426969}, {"tx_hash": "8f3a379d086d9c1f129ffc0e910eaf4a3577418d206b89a6c5516549ee0acb15", "height": 426969}, {"tx_hash": "5682e7bda3573778079eb61bc8de32d3de534683316d406573bdcfa39a6dc519", "height": 426969}, {"tx_hash": "1216aca61a540b37c444ea3222caf363676e83a63d571f9aea4299741658f8da", "height": 427000}, {"tx_hash": "28ee48cbd530b8c737ad667d0d8a9bdc1871f376b5834d0a4a2cc43ba2d2f09f", "height": 427088}, {"tx_hash": "4ac196a13a52da9b11ec74e92394aabaa96e33851b30786d767d1e7d260e07f9", "height": 427093}, {"tx_hash": "ca8c780048e28bca3875cad2c011bfa2bd699480334367e24c817b674a1970f2", "height": 427101}, {"tx_hash": "51a30708ef865871578bb28396a4f0278e1e34a7963b50ac6828f14cff50c3b0", "height": 427111}, {"tx_hash": "48239e6558c582aa15581901117313aceb9a18df6ed6221481a58849345b6e39", "height": 427114}, {"tx_hash": "e6b3731efb83f04cea1989a8fb2f51749174814a89015418f988f03665bed6ab", "height": 427117}, {"tx_hash": "6d45fe4b12ed73e7dd1a9920ff205494141848b0873abee81566205dabd83e88", "height": 427118}, {"tx_hash": "836c22323367d95af4059b0cde3120f76c22f59a2af41215dce3d7e6bf6993d4", "height": 427124}, {"tx_hash": "86fcba6064c114b53d35f07dadaf44459f87d5a7cad4027af61c4762f20c6aac", "height": 427125}, {"tx_hash": "2c3bce28d29047bc6603362ecfd48ce0c7ddcb54153ef2dc194ddf39256d8809", "height": 427126}, {"tx_hash": "647ea029df64cdc5513c9776536e5cf0a5f5ef5632c9931018cd1a15ad7e9988", "height": 427126}, {"tx_hash": "24a0ebcf2cd28be7a3fe0f2cd35d488464bd9dbec4663808a38a7ed8387c22aa", "height": 427174}, {"tx_hash": "2c2672e1c79e5783a7a9ce602296692519aa21259229e3e7f684d76669ebf64b", "height": 427600}, {"tx_hash": "e6de1488a1252cd904f404e8cedb9d63d81b544d4331d6490044c1dea5a80b6d", "height": 427655}, {"tx_hash": "e38c64937b7ace1beca225ad9c458065e2cc1743ff295290a7650e33748cb143", "height": 428132}], "id": 586}

Short version of error:
{"jsonrpc": "2.0", "result": {"hex": "01000000d3ebe45b03c4a385bb104b594c70a0899cf025b276e370cacfb{"jsonrpc": "2.0", "result": [{"tx_hash":

Should I make a PR and in onMessage add try-catch for JSON.parse and delete invalid message?

Thnk you,
Florin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant