JS Extension crash after suspend

@ben,

On another topic: with this test program I also saw 2 crashes. Before your change and after, so I suspect this is something totally different. I can’t reproduce it (yet), but maybe this hint does help you:

 MOO: reached end of buffer while parsing header
<- undefined undefined undefined 
/home/harry/dev/ROPIEEE/roon-ext-test/node_modules/node-roon-api/moo.js:187
    let cb = this.requests[msg.request_id].cb;
                                           ^

TypeError: Cannot read property 'cb' of undefined
    at Moo.handle_response (/home/harry/dev/ROPIEEE/roon-ext-test/node_modules/node-roon-api/moo.js:187:44)
    at Transport.transport.onmessage.msg [as onmessage] (/home/harry/dev/ROPIEEE/roon-ext-test/node_modules/node-roon-api/lib.js:419:27)
    at WebSocket.Transport.ws.onmessage (/home/harry/dev/ROPIEEE/roon-ext-test/node_modules/node-roon-api/transport-websocket.js:30:14)
    at WebSocket.onMessage (/home/harry/dev/ROPIEEE/roon-ext-test/node_modules/ws/lib/WebSocket.js:442:14)

The branch took off from an older commit, so other recent changes are not in (don’t know if this is critical)

This issue is in need for a way to reproduce it, please keep on trying :wink:

There is also an issue for it on GitHub

Hi,

Ok, I can reproduce this…

I’m running this extension on my laptop, and every time I put my laptop in suspend and come back from it the extension crashes (or has already crashed).

2 Likes

I guess that is another (more extreme) way to suspend execution :slight_smile:

I have not looked under the hood, but I am guessing that somewhere that is a hash of messages sent that are expecting a response each with a timeout. On a timeout a messages awaiting a response is removed, then eventually a delayed response message arrives and by that time the message in no longer ion the hash and end result is exception when dereferencing the callback handler.

Assuming something like the above, then in node it is very easy provoke such a problem because of the single threaded co-operative nature of it. It just takes one bit of code somewhere to take too long on some synchronous operation.

I moved everything about the crash into a new thread so I can keep track of everything more easily.

“this extension” here means the test one from the other thread? Pairing Core functionality issue for reference.

I think I have a fix, see: https://github.com/RoonLabs/node-roon-api/tree/crash-on-suspend and let me know if you have any other problems.

I’m going to try to get this and the pairing issue merged into master and a new version number released in the next couple days.

1 Like

Hi @ben,

Thanks for looking into this!

I’ve been testing this. The good news is that the crash is gone.

However, for some reason the extension stops receiving any update what so ever, basically leaving it ‘stuck’ in it’s state.

So I guess that this makes things worse: I’d rather have an extension crashing so it can be restarted then the extension just going silent.

Hope this helps somewhat. If you need me to do some more testing then let me know.

Regards,