LearnNewsExamplesServices
Frontmatter
id1136
titleworker.Base: onMessage() => remove the try catch block
stateClosed
labels
enhancement
assigneestobiu
createdAtAug 27, 2020, 4:16 PM
updatedAtAug 27, 2020, 4:27 PM
githubUrlhttps://github.com/neomjs/neo/issues/1136
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtAug 27, 2020, 4:27 PM

worker.Base: onMessage() => remove the try catch block

Closed v8.1.0 enhancement
tobiu
tobiu commented on Aug 27, 2020, 4:16 PM
    onMessage(e) {
        let me      = this,
            data    = e.data,
            action  = data.action,
            replyId = data.replyId,
            promise;

        if (!action) {
            throw new Error('Message action is missing: ' + data.id);
        }

        if (action !== 'reply') {
            try {
                this['on' + Neo.capitalize(action)](data);
            } catch(err) {
                console.log('error', data, err, e);

                this.reject(data.id, {
                    error : err.message
                });
            }
        } else if (promise = action === 'reply' && me.promises[replyId]) {
            if (data.reject) {
                promise.reject(data.data);
            } else {
                promise.resolve(data.data);
            }

            delete me.promises[replyId];
        }
    }

the try check was from a time, where errors inside a worker did not get logged inside the chrome devtools.

it should be safe to just remove it:

    onMessage(e) {
        let me      = this,
            data    = e.data,
            action  = data.action,
            replyId = data.replyId,
            promise;

        if (!action) {
            throw new Error('Message action is missing: ' + data.id);
        }

        if (action !== 'reply') {
            me['on' + Neo.capitalize(action)](data);
        } else if (promise = action === 'reply' && me.promises[replyId]) {
            if (data.reject) {
                promise.reject(data.data);
            } else {
                promise.resolve(data.data);
            }

            delete me.promises[replyId];
        }
    }
tobiu added the enhancement label on Aug 27, 2020, 4:16 PM
tobiu assigned to @tobiu on Aug 27, 2020, 4:16 PM
tobiu referenced in commit f861e67 - "worker.Base: onMessage() => remove the try catch block #1136" on Aug 27, 2020, 4:19 PM
tobiu closed this issue on Aug 27, 2020, 4:27 PM