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

This commit is contained in:
Robert Monfera 2019-01-22 15:24:25 +01:00 committed by GitHub
parent 57849623fa
commit a5f7b68af2
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);