Skip to content

simpleWorker reporting "Cannot read property 'vsWorker' of undefined" #766

@jjyyxx

Description

@jjyyxx

monaco-editor version: 0.11.1
Browser: Chrome 64
OS: Windows 10
Steps or JS usage snippet reproducing the issue: Configure a develop environment using webpack and webpackDevServer. The dev server would post a message with type webpackOk (when the client-side dev server plugin is ready, I think).

    self.postMessage({
        type: 'webpack' + type,
        data: data
    }, '*');

In editor.worker.js, the worker received the message and passed the message to simpleWorker.js to handle.

    SimpleWorkerProtocol.prototype.handleMessage = function (serializedMessage) {  // got an object
        var message;
        try {
            message = JSON.parse(serializedMessage);
        }
        catch (e) {
            // nothing
        }
        if (!message.vsWorker) {
            return;
        }
        if (this._workerId !== -1 && message.vsWorker !== this._workerId) {
            return;
        }
        this._handleMessage(message);
    };

So in line 9 in simpleWorker.js, "Cannot read property 'vsWorker' of undefined" is thrown.

I think maybe we shall check if message === undefined first or simply ignore message with type prefix webpack?

If anyone thinks the webpack config file is necessary to provide more information, I would be happy to post it.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions