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

Disconnect crash #5

Open
CWBudde opened this issue Oct 21, 2021 · 2 comments
Open

Disconnect crash #5

CWBudde opened this issue Oct 21, 2021 · 2 comments

Comments

@CWBudde
Copy link
Contributor

CWBudde commented Oct 21, 2021

I am running this for 3 days continously, but it has crashed at least two times noe.

The latest one I catched in the console:

CallMonitor/node_modules/node-fritzbox-callmonitor/index.js:99
      self.call[data[2]].disconnect = data[0];
                                    ^

TypeError: Cannot set property 'disconnect' of undefined
    at Socket.<anonymous> (/Users/gabi/Library/CallMonitor/node_modules/node-fritzbox-callmonitor/index.js:99:37)
    at Socket.emit (events.js:400:28)
    at addChunk (internal/streams/readable.js:293:12)
    at readableAddChunk (internal/streams/readable.js:267:9)
    at Socket.Readable.push (internal/streams/readable.js:206:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
Cannot set property 'disconnect' of undefined

It would be nice if the script would not just crash, but just continue to run in some way.

@CWBudde
Copy link
Contributor Author

CWBudde commented Oct 21, 2021

It just happened again. Proposal:

Rewrite:

    if (data[1] === 'disconnect') {
      self.call[data[2]].disconnect = data[0];
      self.call[data[2]].duration   = parseInt(data[3], 10);

      var call = self.call[data[2]];
      delete(self.call[data[2]]);
      self.emit('disconnected', call);
      return;

to something like this (untested code, just out of my head):

    if (data[1] === 'disconnect') {
      var call = self.call[data[2]] ?? {};
      call.disconnect = data[0];
      call.duration   = parseInt(data[3], 10);
      self.emit('disconnected', call);
      return;

@CWBudde
Copy link
Contributor Author

CWBudde commented Oct 21, 2021

Eventually I was running the same script twice in parallel. This might have been the reason for the crash, but I'm not deep into the code to judge it.

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