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.

Crash when showing an alert

See original GitHub issue

I have tested this on Windows 10 x64 and MacOS (whatever the most recent is, I don’t remember), in NW.js versions 0.17.0 and 0.14.7. All of those combinations have the following problem.

I have an application that is using NW.js to show a website to users who do not have Chrome installed on their machines. The website opens a WebSocket connection to another server. If the server closes the WebSocket, the website shows an alert, clears its session, and redirects the user back to the login page.

When the alert is supposed to show, NW.js crashes with the following messages on the console:

[0907/125520:ERROR:process_info.cc(608)] range at 0x42d2d6c00000000, size 0x1f1 fully unreadable
[0907/125520:ERROR:process_info.cc(608)] range at 0x42d2d8c00000000, size 0x1f1 fully unreadable
[0907/125520:ERROR:process_info.cc(608)] range at 0x42d2d8e00000000, size 0x1f1 fully unreadable

nw.js exits with code 3221225477.

(The range at 0xXXXX, size 0xXXX numbers vary, but all the rest is the same.)

For background, here’s the (ES6 version of the) code for the WebSocket handler. The actual project uses a transpiled ES5 version because it has to run in browsers, but this should be all that is needed for illustration of the issue.

import WildEmitter from 'wildemitter';

export default class SocketManager {
    constructor(url, username, password) {
        this._ws = new WebSocket(url);

        this._ws.onopen = (evt) => {
            this.send({
              type: 'connect',
              user: username,
              pass: password
            });
        };

        this._ws.onerror = (evt) => {
            this.emit('error', evt);
        };

        this._ws.onclose = (evt) => {
            this.emit('closed');
        };
        this._ws.onmessage = ({data: data}) => {
            var obj = null;
            try {
                obj = JSON.parse(data);
            } catch(err) {
                this.emit('error', `invalid message: ${data}`);
                return;
            }
            if (obj.type) {
                this.emit(`message.${obj.type}`, obj);
            } else {
                this.emit('message.unknown_type', obj);
            }
        };

    }

    send(message) {
        if (this._ws && this._ws.readyState === WebSocket.OPEN) {
            var messageStr = JSON.stringify(message);
            this.emit('sending', messageStr);
            this._ws.send(messageStr);
        } else {
            throw new Error('Unable to send on WebSocket: WebSocket is not open');
        }
    }

    close() {
        if (this._ws) {
            return this._ws.close();
        } else {
            return true;
        }
    }
}

WildEmitter.mixin(SocketManager);

Here is the code where the crash occurs:

socket.on('message.error', function(message) {
    alert(message.errorText);
});

<strike>The crash happens just before the native WebSocket onclose event would be fired - breakpoints in the DevTools show that the last incoming message is received and then the crash happens before the breakpoint on this.emit('closed'); (inside this._ws.onclose) can be reached.</strike>

The website works fine in Chrome, in all versions released in the last 8 months.

Here are some crash dumps: reports.zip

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

0reactions
kohenkatzcommented, Sep 14, 2016

@rogerwang I can confirm that it works.

I’m curious if you can point to where in the code this was?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use Crash Detection on iPhone or Apple Watch to call for help ...
When a severe car crash is detected, your iPhone or Apple Watch sounds an alarm and displays an alert1. Your iPhone reads the...
Read more >
display UIAlert will crash the app on present? - Stack Overflow
Show activity on this post. I had a similar issue. Answering here if someone else encounters it. The app can also crash in...
Read more >
Customize velocity alerts - Crashlytics - Firebase - Google
By default, Firebase can send Crashlytics alerts via email. For velocity alerts and regressions, Firebase can also show these alerts in the Firebase...
Read more >
iPhone 14 crash detection alerts rescuers to fatal accident - BGR
The iPhone 14's Crash Detection feature will run a countdown timer before calling rescuers when the device detects an accident. The owner can ......
Read more >
iPhone 14 crash detection alert was triggered by a ... - ZDNet
Crash Detection on the iPhone 14 is only meant to call emergency services when it detects you've been in a crash, but apparently...
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