0|server | TypeError: Cannot set property 'id' of undefined
0|server | at WebsocketProvider._callee2$ (/var/www/exnce/node_modules/web3-providers/dist/web3-providers.cjs.js:266:44)
0|server | at tryCatch (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:45:40)
0|server | at Generator.invoke [as _invoke] (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:271:22)
0|server | at Generator.prototype.(anonymous function) [as next] (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:97:21)
0|server | at asyncGeneratorStep (/var/www/exnce/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
0|server | at _next (/var/www/exnce/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
0|server | at <anonymous>
0|server | at process._tickCallback (internal/process/next_tick.js:188:7)
Could you add a repository with an example where I can reproduce this issue?
make a socket connection to infura
wss://mainnet.infura.io/ws/v3/YOUR_PRIVATE_API_KEY
subscribe transactions... every 3-5 hours u will get this exception...
Did your laptop fall asleep? I have got the same error after my laptop awaken.
no, im getting this problem on my webserver...
Error: Node error: {"code":-32603,"message":"request failed or timed out"}
at Function.validate (/var/www/exnce/node_modules/web3-providers/dist/web3-providers.cjs.js:111:18)
at WebsocketProvider._callee$ (/var/www/exnce/node_modules/web3-providers/dist/web3-providers.cjs.js:185:61)
at tryCatch (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:45:40)
at Generator.invoke [as _invoke] (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:271:22)
at Generator.prototype.(anonymous function) [as next] (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:97:21)
at asyncGeneratorStep (/var/www/exnce/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (/var/www/exnce/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
Error: Node error: {"code":-32603,"message":"request failed or timed out"}
at Function.validate (/var/www/exnce/node_modules/web3-providers/dist/web3-providers.cjs.js:111:18)
at WebsocketProvider._callee$ (/var/www/exnce/node_modules/web3-providers/dist/web3-providers.cjs.js:185:61)
at tryCatch (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:45:40)
at Generator.invoke [as _invoke] (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:271:22)
at Generator.prototype.(anonymous function) [as next] (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:97:21)
at asyncGeneratorStep (/var/www/exnce/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (/var/www/exnce/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
Error: Node error: {"code":-32603,"message":"request failed or timed out"}
at Function.validate (/var/www/exnce/node_modules/web3-providers/dist/web3-providers.cjs.js:111:18)
at WebsocketProvider._callee$ (/var/www/exnce/node_modules/web3-providers/dist/web3-providers.cjs.js:185:61)
at tryCatch (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:45:40)
at Generator.invoke [as _invoke] (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:271:22)
at Generator.prototype.(anonymous function) [as next] (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:97:21)
at asyncGeneratorStep (/var/www/exnce/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (/var/www/exnce/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
Error: Node error: {"code":-32603,"message":"request failed or timed out"}
at Function.validate (/var/www/exnce/node_modules/web3-providers/dist/web3-providers.cjs.js:111:18)
at WebsocketProvider._callee$ (/var/www/exnce/node_modules/web3-providers/dist/web3-providers.cjs.js:185:61)
at tryCatch (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:45:40)
at Generator.invoke [as _invoke] (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:271:22)
at Generator.prototype.(anonymous function) [as next] (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:97:21)
at asyncGeneratorStep (/var/www/exnce/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (/var/www/exnce/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
TypeError: Cannot set property 'id' of undefined
at WebsocketProvider._callee2$ (/var/www/exnce/node_modules/web3-providers/dist/web3-providers.cjs.js:266:44)
at tryCatch (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:45:40)
at Generator.invoke [as _invoke] (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:271:22)
at Generator.prototype.(anonymous function) [as next] (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:97:21)
at asyncGeneratorStep (/var/www/exnce/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (/var/www/exnce/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
I was running several subscriptions on my MacBook and on my gamer PC. My MacBook had sometimes no internet connection, was falling asleep, and I've closed and opened it over the day serveral times and no error got thrown.
can u share your sample source in here? because im still getting this error
I think it's a problem with Websocket connection to the node.. for ex Infura
I will try to use this code to handle problem...
` // Listen for connection events
this.provider.on('connect', () => logger.info('Web3 Provider connected.'));
this.provider.on('error', e => this.handleDisconnects(e));
this.provider.on('end', e => this.handleDisconnects(e));`
Today I got this exception again...
(node:1) UnhandledPromiseRejectionWarning: TypeError: Cannot set property 'id' of undefined
at WebsocketProvider._callee2$ (/app/node_modules/web3-providers/dist/web3-providers.cjs.js:268:44)
at tryCatch (/app/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:45:40)
at Generator.invoke [as _invoke] (/app/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:271:22)
at Generator.prototype.(anonymous function) [as next] (/app/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:97:21)
at asyncGeneratorStep (/app/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (/app/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Part of my code below:
`
this.provider = new Web3.providers.WebsocketProvider('wss://ropsten.infura.io/ws/v3/API_KEY');
this.web3 = new Web3(this.provider);
this.newPendingTransactionEvent = this.web3.eth.subscribe('pendingTransactions');
this.newPendingTransactionEvent
.on('data', (hash) => {
logger.error('Pending transaction');
})
.on('error', (err) => {
logger.error('Pending transaction error');
});
`
I have opened this file web3-providers/dist/web3-providers.cjs.js
and have found this string:
` case 7:
subscriptionId = _context2.sent;
delete this.subscriptions[subscriptionId];
this.subscriptions[key].id = subscriptionId;
`
Thanks for giving some more details! I will run your example on several PC鈥榮 for some days and simulate the reconnecting and other cases on Monday. Is there a repository you could provide for seeing the project setup you have?
My apologies, but it's a private repository. I can share some part of the code if you need it. I am very interesting in it. It happens rarely, for example I have got only one case for two days...
It seems to me that problem hides in this function.
Because in another cases we previously check the length of object... for ex case 3:
if (!(_i < _subscriptionKeys.length)) {
_context2.next = 13;
break;
}
and starts new connection... but in case 7: did't...
And one more thing... I have got this exception on two independent instances at the same time (azure vm and my dev laptop) after block ->
info: New Block: 5571430 {"timestamp":"2019-05-10T19:02:50.347Z"}
Yesterday I got this exception several times, I was subscribed on new block headers in Infura Ropsten.
i fixed it already...
How you did it?
@nivida add a try catch man! our applications are crashing because of this...
try/catch is definitely not the solution. A contributor created a PR with the correct fix. It isn鈥檛 directly a problem of web3.js the real problem is that infura is returning the same subscription id for a already closed subscription. The correct behavior of infura would be to return a new subscription id. :)
great, @nivida #2811 i will test it...
0|server | (node:12145) Warning: N-API is an experimental feature and could change at any time.
0|server | TypeError: Cannot set property 'id' of undefined
0|server | at WebsocketProvider._callee2$ (/var/www/exnce/node_modules/web3-providers/dist/web3-providers.cjs.js:268:44)
0|server | at tryCatch (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:45:40)
0|server | at Generator.invoke [as _invoke] (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:271:22)
0|server | at Generator.prototype.(anonymous function) [as next] (/var/www/exnce/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:97:21)
0|server | at asyncGeneratorStep (/var/www/exnce/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
0|server | at _next (/var/www/exnce/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
0|server | at
0|server | at process._tickCallback (internal/process/next_tick.js:188:7)
0|server | (node:12308) Warning: N-API is an experimental feature and could change at any time.
@nivida v1.0.0-beta.55 still have this problem...
New build has not released yet...
Was this merged in 2.x branch? Or is it available in 1.0?
2.x
Damnit. I think I will be stuck with an unstable version of web3 forever.
It is problem of infura...
Most helpful comment
can u share your sample source in here? because im still getting this error