question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Another "Cannot read property 'setTimeout' of undefined" crash when Steam goes down

See original GitHub issue

Describe the bug

When Steam went down at midnight Aug 4 2020 another crash exception occurred in the connection.js file similar to https://github.com/DoctorMcKay/node-steam-user/issues/274 - but instead of occurring in ChannelEncryptRequest it happens in ChannelEncryptResult.

Versions

What version of the module and what version of Node.js are you using? Node.js: v12.16.1 node-steam-user: 4.17.1

Screenshots and Error Logs

If applicable, add screenshots and error logs to help explain your problem.

From what I can see, Steam went down and the bots called logOn a few minutes earlier before crashing. I have a feeling I get these crashes because my bots are re-logging into Steam (this is with an interval and timeout however). Nonetheless this isn’t a great exception to have possible in the module.

2020-08-04T23:20:25.567Z [app.js] ERROR uncaughtException: Cannot read property 'setTimeout' of undefined
TypeError: Cannot read property 'setTimeout' of undefined
    at SteamUser.<anonymous> (/app/node_modules/steam-user/components/connection.js:54:26)
    at /app/node_modules/steam-user/components/classes/HandlerManager.js:37:12
    at Array.forEach (<anonymous>)
    at HandlerManager.emit (/app/node_modules/steam-user/components/classes/HandlerManager.js:36:12)
    at SteamUser._handleMessage (/app/node_modules/steam-user/components/messages.js:569:24)
    at SteamUser._handleNetMessage (/app/node_modules/steam-user/components/messages.js:504:7)
    at TCPConnection._readMessage (/app/node_modules/steam-user/components/connection_protocols/tcp.js:193:12)
    at Socket.emit (events.js:311:20)
    at emitReadable_ (_stream_readable.js:562:12)
    at processTicksAndRejections (internal/process/task_queues.js:83:21)

I suppose the solution could again be the fix used before where it will not continue handling this message unless a socket is available. I’m going to continue trying to debug why this crash occurred, but if I don’t have any luck I’ll submit a PR with the same return logic as before.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
itsjfxcommented, Sep 23, 2020

I think what might be happening is Steam goes down, steam-user disconnects, steamcommunity therefore has its session expire, and your code to call logOn gets executed. But steam-user is already internally trying to reconnect, so things get out of sorts.

You shouldn’t ever need to call logOn again unless you specifically get an error event.

Yep I was just about to comment this lol. Alternatively you could also disable auto relogging and implement it yourself if you’d prefer to do that (but node-steam-user has a really nice fallback system for relogging in place, so I’d recommend against).

0reactions
DoctorMcKaycommented, Jul 23, 2021

I believe he’s referring to this event called in node-steam-user: https://github.com/DoctorMcKay/node-steam-user#error

I think only call webLogon in sessionExpired IF client.steamID is defined - otherwise do nothing else there. And then in the error event in node-steam-user (the one linked above) login again if that event runs.

You should assume that if your web session expires and node-steam-user is logged out it is already trying to log back in (unless error event runs).

These are my assumptions but I believe they are correct.

I realize this is a very late response, but your assumptions are correct.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error "Cannot read property of undefined" when wrapped in a ...
I have been working on a piece of code that is meant to handle multiple, small video elements on a single webpage but...
Read more >
setTimeout(function(){throw null},0) crashes toplevel #12373
If I run. setTimeout(function() { throw null }, 0). the REPL crashes with. TypeError: Cannot read property 'stack' of null at Domain.
Read more >
r/Steam Monthly Community Support Thread. - Reddit
Welcome to the Community Support Thread! This Steam Guide goes over how to troubleshoot download and connection issues.
Read more >
Bug listing with status RESOLVED with resolution FIXED as at ...
Bug :2 - "How do I attach an ebuild. ... resolution:FIXED severity:enhancement · Bug:425 - "PyQt requires dev-python/sip-3.0 but emerge doesn't detect this....
Read more >
setTimeout() - Web APIs - MDN Web Docs
The global setTimeout() method sets a timer which executes a function or specified piece of code once the timer expires.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found