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

Subscribe to pendingTransactions fails while using IPC Provider #2539

Closed
MaxFriedman17 opened this issue Mar 20, 2019 · 1 comment · Fixed by #2545
Closed

Subscribe to pendingTransactions fails while using IPC Provider #2539

MaxFriedman17 opened this issue Mar 20, 2019 · 1 comment · Fixed by #2545
Labels
Bug Addressing a bug

Comments

@MaxFriedman17
Copy link

MaxFriedman17 commented Mar 20, 2019

Description

Subscribing to pending transactions gives an error and exits the program while using IPC connection.

Expected behavior

Subscribing to new pending transaction (web3.eth.subscribe('pendingTransactions')) is expected to return a json response with a txhash of new transaction.

Actual behavior

It returns a json response but it terminates the execution of the program with an error (see in Error logs section the actual error message).

I actually tried to debug the code and it seems that it fails here:

if (!isObject(response)) {
        response = JSON.parse(response);
      }

while trying to parse the JSON response that comes from the IPC pipe. It seems that in the variable response it appears not only the JSON response of the pending transaction but also the first response that gives the subscription ID when starting the subscription to the node so it fails to parse that object to json.
(This is my interpretation, it can be another thing but hope this helps to fix the problem but if it is this, maybe other subscription types -like block headers- will fail as well).

Steps to reproduce the behavior

  1. Import web3
  2. Set IPC Provider
  3. Subscribe to new pending transactions.

Error Logs

SyntaxError: Unexpected token { in JSON at position 71
at JSON.parse ()
at IpcProvider.onMessage (/node_modules/web3-providers/dist/web3-providers.cjs.js:285:25)
at IpcProvider.onMessage (/node_modules/web3-providers/dist/web3-providers.cjs.js:551:71)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at Pipe.onread (net.js:607:20)

Versions

  • web3.js: 1.0.0-beta.50
  • nodejs: v 8.10.0
  • browser: -
  • ethereum node: geth v1.8.23-stable-c9427004

Regards!

@nivida nivida added the Bug Addressing a bug label Mar 20, 2019
@nivida
Copy link
Contributor

nivida commented Mar 20, 2019

Thanks for opening this issue! I will fix and release it asap.

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

Successfully merging a pull request may close this issue.

2 participants