Skip to content
Snippets Groups Projects
Unverified Commit 081b98cc authored by Jed Fox's avatar Jed Fox Committed by GitHub
Browse files

Don’t post messages to the worker until it is ready (#681)

parent f43041a3
No related branches found
No related tags found
No related merge requests found
......@@ -88,7 +88,7 @@ function connectWorker(worker, onOpen, onError) {
// Send any messages that were queued while closed
if (messageQueue.length > 0) {
messageQueue.forEach(msg => worker.postMessage(msg));
messageQueue = [];
messageQueue = null;
}
onOpen();
......@@ -138,22 +138,17 @@ module.exports.send = function send(name, args, { catchErrors = false } = {}) {
return new Promise((resolve, reject) => {
uuid.v4().then(id => {
replyHandlers.set(id, { resolve, reject });
if (globalWorker) {
globalWorker.postMessage({
id,
name,
args,
undoTag: undo.snapshot(),
catchErrors,
});
let message = {
id,
name,
args,
undoTag: undo.snapshot(),
catchErrors,
};
if (messageQueue) {
messageQueue.push(message);
} else {
messageQueue.push({
id,
name,
args,
undoTag: undo.snapshot(),
catchErrors,
});
globalWorker.postMessage(message);
}
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment