Listen to Compiled Source Errors in JSCExecutor fallback code.

Reviewed By: javache

Differential Revision: D4284537

fbshipit-source-id: 247717ef55fb6bc0a34a01626c790bd23fd18598
This commit is contained in:
Ashok Menon 2016-12-08 05:08:16 -08:00 committed by Facebook Github Bot
parent 286095292f
commit 624104fd0c
1 changed files with 17 additions and 2 deletions

View File

@ -379,12 +379,27 @@ void JSCExecutor::loadApplicationScript(
{
String jsSourceURL(m_context, sourceURL.c_str());
auto bcSourceCode = JSCreateCompiledSourceCode(fd, jsSourceURL);
if (!bcSourceCode) {
JSCompiledSourceError jsError;
auto bcSourceCode = JSCreateCompiledSourceCode(fd, jsSourceURL, &jsError);
if (jsError == JSCompiledSourceErrorOnRead ||
jsError == JSCompiledSourceErrorNotCompiled) {
// Not bytecode, fall through.
return JSExecutor::loadApplicationScript(fd, sourceURL);
} else if (jsError == JSCompiledSourceErrorVersionMismatch) {
throw std::runtime_error("Compiled Source Version Mismatch");
}
folly::throwOnFail<std::runtime_error>(
jsError == JSCompiledSourceErrorNone,
"Unhandled Compiled Source Error"
);
folly::throwOnFail<std::runtime_error>(
bcSourceCode != nullptr,
"Unexpected error opening compiled bundle"
);
ReactMarker::logMarker("RUN_JS_BUNDLE_START");
evaluateSourceCode(m_context, bcSourceCode, jsSourceURL);