Fix: avoid server crash when no value is found (#29069) (#29105)

This commit is contained in:
Robert Monfera 2019-01-22 17:33:24 +01:00 committed by GitHub
parent 5de4f1c58f
commit 517b6dd631
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,12 +37,14 @@ export function getWorker() {
if (type === 'run') {
const { threadId } = msg;
const { ast, context } = value;
heap[threadId]
.onFunctionNotFound(ast, context)
.then(value => {
worker.send({ type: 'msgSuccess', id, value: value });
})
.catch(e => heap[threadId].reject(e));
if (heap[threadId]) {
heap[threadId]
.onFunctionNotFound(ast, context)
.then(value => {
worker.send({ type: 'msgSuccess', id, value: value });
})
.catch(e => heap[threadId].reject(e));
}
}
if (type === 'msgSuccess' && heap[id]) heap[id].resolve(value);