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

Avoid "notify called synchronously" when port callbacks throw #374

Closed
rtfeldman opened this Issue Aug 27, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@rtfeldman
Member

rtfeldman commented Aug 27, 2015

See elm/error-message-catalog#31 for original discussion.

This code is a workaround for end users until core has a fix:

function safeSubscribe(ports, name, callback) {
    ports[name].subscribe(function(value) {
        try {
            callback(value);
        } catch(e) {
            setTimeout(function() {
                // rethrow things how you want, mention 'name' so you know who caused it
            }, 0);
        }
    });
}

Per @evancz, should be a tiny fix here.

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Sep 22, 2016

Member

notify does not exist anymore, so this cannot be a thing anymore. (I'm pretty sure!)

Member

evancz commented Sep 22, 2016

notify does not exist anymore, so this cannot be a thing anymore. (I'm pretty sure!)

@evancz evancz closed this Sep 22, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment