Non-fatal compile_sync failures (#2039)

And model worker resources as Stream
This commit is contained in:
andy finch 2019-04-04 05:33:32 -04:00 committed by Ryan Dahl
parent 8c85766198
commit 0e7311e171
11 changed files with 228 additions and 98 deletions

View file

@ -47,6 +47,7 @@ interface CompilerLookup {
specifier: ModuleSpecifier;
referrer: ContainingFile;
isWorker: boolean;
cmdId: number;
}
/** Abstraction of the APIs required from the `os` module so they can be
@ -522,11 +523,22 @@ window.TextEncoder = TextEncoder;
window.compilerMain = function compilerMain() {
// workerMain should have already been called since a compiler is a worker.
window.onmessage = ({ data }: { data: CompilerLookup }) => {
const { specifier, referrer } = data;
const { specifier, referrer, cmdId } = data;
const result = compiler.compile(specifier, referrer);
postMessage(result);
try {
const result = compiler.compile(specifier, referrer);
postMessage({
success: true,
cmdId,
data: result
});
} catch (e) {
postMessage({
success: false,
cmdId,
data: JSON.parse(core.errorToJSON(e))
});
}
};
};