From 85478b56c58ff48acf750e4f3d3a17ba8607b52b Mon Sep 17 00:00:00 2001 From: Ashok Menon Date: Thu, 8 Dec 2016 05:08:16 -0800 Subject: [PATCH] Listen to Compiled Source Errors in JSCExecutor fallback code. Reviewed By: javache Differential Revision: D4284537 fbshipit-source-id: 247717ef55fb6bc0a34a01626c790bd23fd18598 --- ReactCommon/cxxreact/JSCExecutor.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ReactCommon/cxxreact/JSCExecutor.cpp b/ReactCommon/cxxreact/JSCExecutor.cpp index 17881da87d9..6e57f5a4280 100644 --- a/ReactCommon/cxxreact/JSCExecutor.cpp +++ b/ReactCommon/cxxreact/JSCExecutor.cpp @@ -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( + jsError == JSCompiledSourceErrorNone, + "Unhandled Compiled Source Error" + ); + + folly::throwOnFail( + bcSourceCode != nullptr, + "Unexpected error opening compiled bundle" + ); + ReactMarker::logMarker("RUN_JS_BUNDLE_START"); evaluateSourceCode(m_context, bcSourceCode, jsSourceURL);