The Debug build of our React Native Windows project is failing to load a JS bundle file when loading directly from disk (instead of using metro hot-loading). The exception only occurs when using an optimized release version of hermes.dll from our Debug application. Specifically, we are using the checkediterdebugger version of the Release build for hermes.dll included in the ReactNative.Hermes.Windows.0.9.0-ms.4 NuGet package.
Everything works as expected when using a Release build of the application with the Release build of hermes.dll.
The Debug build will also load the bundle successfully while a Visual Studio debugger is attached by simply hitting 'continue'. It looks like this exception is not caught by any try-catch blocks, but the program is able to continue along as if nothing happened if we simply hit 'continue' from the debugger. In this case, everything seems to work as expected If a debugger is not attached then the program crashes before the bundle loads.
Please note that our scenario uses XAML Islands to host the UWP XAML control inside a DesktopWindowXamlSource object so that we can run React Native from an unpackaged Win32 application.
ntdll.dll!00007ffef348bda2() Unknown
ntdll.dll!00007ffef3494c02() Unknown
ntdll.dll!00007ffef3494eea() Unknown
ntdll.dll!00007ffef349f3d5() Unknown
ntdll.dll!00007ffef342e012() Unknown
ntdll.dll!00007ffef33a7511() Unknown
ucrtbase.dll!00007ffef110218b() Unknown
[Inline Frame] hermes.dll!std::_Deallocate(void * _Ptr, unsigned __int64 _Bytes) Line 264 C++
[Inline Frame] hermes.dll!std::allocator<facebook::jsi::PropNameID>::deallocate(facebook::jsi::PropNameID * const) Line 835 C++
[Inline Frame] hermes.dll!std::vector<facebook::jsi::PropNameID,std::allocator<facebook::jsi::PropNameID>>::_Tidy() Line 1765 C++
hermes.dll!std::vector<facebook::jsi::PropNameID,std::allocator<facebook::jsi::PropNameID>>::~vector<facebook::jsi::PropNameID,std::allocator<facebook::jsi::PropNameID>>() Line 712 C++
> hermes.dll!facebook::hermes::HermesRuntimeImpl::JsiProxy::getHostPropertyNames() Line 955 C++
[Inline Frame] hermes.dll!hermes::vm::HostObject::getHostPropertyNames() Line 120 C++
hermes.dll!hermes::vm::JSObject::getOwnPropertyKeys(hermes::vm::Handle<hermes::vm::JSObject> selfHandle, hermes::vm::Runtime * runtime, hermes::vm::OwnKeysFlags okFlags) Line 443 C++
hermes.dll!hermes::vm::getOwnPropertyKeysAsStrings(hermes::vm::Handle<hermes::vm::JSObject> selfHandle, hermes::vm::Runtime * runtime, hermes::vm::OwnKeysFlags okFlags) Line 447 C++
hermes.dll!hermes::vm::objectGetOwnPropertyNames(void * __formal, hermes::vm::Runtime * runtime, hermes::vm::NativeArgs args) Line 484 C++
[Inline Frame] hermes.dll!hermes::vm::NativeFunction::_nativeCall(hermes::vm::NativeFunction *) Line 546 C++
hermes.dll!hermes::vm::Interpreter::handleCallSlowPath(hermes::vm::Runtime * runtime, hermes::vm::PinnedHermesValue * callTarget) Line 285 C++
hermes.dll!hermes::vm::Interpreter::interpretFunction<0,0>(hermes::vm::Runtime * runtime, hermes::vm::InterpreterState & state) Line 1633 C++
[Inline Frame] hermes.dll!hermes::vm::Runtime::interpretFunctionImpl(hermes::vm::CodeBlock *) Line 818 C++
hermes.dll!hermes::vm::Runtime::interpretFunction(hermes::vm::CodeBlock * newCodeBlock) Line 832 C++
hermes.dll!hermes::vm::JSFunction::_callImpl(hermes::vm::Handle<hermes::vm::Callable> selfHandle, hermes::vm::Runtime * runtime) Line 1284 C++
[Inline Frame] hermes.dll!hermes::vm::Callable::call(hermes::vm::Handle<hermes::vm::Callable>) Line 275 C++
hermes.dll!hermes::vm::Callable::executeCall0(hermes::vm::Handle<hermes::vm::Callable> selfHandle, hermes::vm::Runtime * runtime, hermes::vm::Handle<hermes::vm::HermesValue> thisArgHandle, bool construct) Line 248 C++
hermes.dll!hermes::vm::JSObject::getNamedWithReceiver_RJS(hermes::vm::Handle<hermes::vm::JSObject> selfHandle, hermes::vm::Runtime * runtime, hermes::vm::SymbolID name, hermes::vm::Handle<hermes::vm::HermesValue> receiver, hermes::vm::PropOpFlags opFlags, hermes::vm::PropertyCacheEntry * cacheEntry) Line 1096 C++
hermes.dll!hermes::vm::Interpreter::interpretFunction<0,0>(hermes::vm::Runtime * runtime, hermes::vm::InterpreterState & state) Line 2387 C++
[Inline Frame] hermes.dll!hermes::vm::Runtime::interpretFunctionImpl(hermes::vm::CodeBlock *) Line 818 C++
hermes.dll!hermes::vm::Runtime::interpretFunction(hermes::vm::CodeBlock * newCodeBlock) Line 832 C++
hermes.dll!hermes::vm::JSFunction::_callImpl(hermes::vm::Handle<hermes::vm::Callable> selfHandle, hermes::vm::Runtime * runtime) Line 1284 C++
[Inline Frame] hermes.dll!hermes::vm::Callable::call(hermes::vm::Handle<hermes::vm::Callable>) Line 275 C++
hermes.dll!hermes::vm::Callable::executeCall0(hermes::vm::Handle<hermes::vm::Callable> selfHandle, hermes::vm::Runtime * runtime, hermes::vm::Handle<hermes::vm::HermesValue> thisArgHandle, bool construct) Line 248 C++
hermes.dll!hermes::vm::JSObject::getNamedWithReceiver_RJS(hermes::vm::Handle<hermes::vm::JSObject> selfHandle, hermes::vm::Runtime * runtime, hermes::vm::SymbolID name, hermes::vm::Handle<hermes::vm::HermesValue> receiver, hermes::vm::PropOpFlags opFlags, hermes::vm::PropertyCacheEntry * cacheEntry) Line 1096 C++
hermes.dll!hermes::vm::Interpreter::interpretFunction<0,0>(hermes::vm::Runtime * runtime, hermes::vm::InterpreterState & state) Line 2387 C++
[Inline Frame] hermes.dll!hermes::vm::Runtime::interpretFunctionImpl(hermes::vm::CodeBlock *) Line 818 C++
hermes.dll!hermes::vm::Runtime::interpretFunction(hermes::vm::CodeBlock * newCodeBlock) Line 832 C++
hermes.dll!hermes::vm::Runtime::runBytecode(std::shared_ptr<hermes::hbc::BCProviderBase> && bytecode, hermes::vm::RuntimeModuleFlags flags, llvh::StringRef sourceURL, hermes::vm::Handle<hermes::vm::Environment> environment, hermes::vm::Handle<hermes::vm::HermesValue> thisArg) Line 1017 C++
[Inline Frame] hermes.dll!hermes::vm::Runtime::runBytecode(std::shared_ptr<hermes::hbc::BCProviderBase> &&) Line 277 C++
hermes.dll!facebook::hermes::HermesRuntimeImpl::evaluatePreparedJavaScript::__l2::<lambda>() Line 1509 C++
[Inline Frame] hermes.dll!?A0xa7b9cf34::maybeRethrow(const facebook::hermes::HermesRuntimeImpl::evaluatePreparedJavaScript::__l2::facebook::jsi::Value <lambda>(void) &) Line 109 C++
[Inline Frame] hermes.dll!facebook::hermes::HermesRuntimeImpl::evaluatePreparedJavaScript(const std::shared_ptr<facebook::jsi::PreparedJavaScript const> &) Line 1499 C++
hermes.dll!facebook::hermes::HermesRuntime::evaluateJavaScriptWithSourceMap(const std::shared_ptr<facebook::jsi::Buffer const> & buffer, const std::shared_ptr<facebook::jsi::Buffer const> & sourceMapBuf, const std::string & sourceURL) Line 1372 C++
hermes.dll!facebook::hermes::HermesRuntimeImpl::evaluateJavaScript(const std::shared_ptr<facebook::jsi::Buffer const> & buffer, const std::string & sourceURL) Line 1522 C++
Microsoft.ReactNative.dll!facebook::jsi::RuntimeDecorator<facebook::hermes::HermesRuntime,facebook::jsi::Runtime>::evaluateJavaScript(const std::shared_ptr<facebook::jsi::Buffer const> & buffer, const std::string & sourceURL) Line 118 C++
Microsoft.ReactNative.dll!facebook::react::JSIExecutor::loadBundle(std::unique_ptr<facebook::react::JSBigString const ,std::default_delete<facebook::react::JSBigString const>> script, std::string sourceURL) Line 159 C++
Microsoft.ReactNative.dll!facebook::react::NativeToJsBridge::loadBundleSync(std::unique_ptr<facebook::react::RAMBundleRegistry,std::default_delete<facebook::react::RAMBundleRegistry>> bundleRegistry, std::unique_ptr<facebook::react::JSBigString const ,std::default_delete<facebook::react::JSBigString const>> startupScript, std::string startupScriptSourceURL) Line 163 C++
Microsoft.ReactNative.dll!facebook::react::Instance::loadBundleSync(std::unique_ptr<facebook::react::RAMBundleRegistry,std::default_delete<facebook::react::RAMBundleRegistry>> bundleRegistry, std::unique_ptr<facebook::react::JSBigString const ,std::default_delete<facebook::react::JSBigString const>> string, std::string sourceURL) Line 89 C++
Microsoft.ReactNative.dll!facebook::react::Instance::loadScriptFromString(std::unique_ptr<facebook::react::JSBigString const ,std::default_delete<facebook::react::JSBigString const>> string, std::string sourceURL, bool loadSynchronously) Line 107 C++
Microsoft.ReactNative.dll!facebook::react::InstanceImpl::loadBundleInternal(std::string && jsBundleRelativePath, bool synchronously) Line 592 C++
Microsoft.ReactNative.dll!facebook::react::InstanceImpl::loadBundleSync(std::string && jsBundleRelativePath) Line 462 C++
Microsoft.ReactNative.dll!Mso::React::ReactInstanceWin::LoadJSBundles::__l7::<lambda>() Line 564 C++
[External Code]
Microsoft.ReactNative.dll!Mso::React::MessageDispatchQueue::tryFunc(const std::function<void __cdecl(void)> & func) Line 41 C++
Microsoft.ReactNative.dll!Mso::React::MessageDispatchQueue::runOnQueue::__l2::<lambda>() Line 36 C++
Microsoft.ReactNative.dll!Mso::Details::FunctionObjectWrapper<void <lambda>(void),void>::Invoke() Line 166 C++
Microsoft.ReactNative.dll!Mso::QueueService::InvokeTask(Mso::Functor<void __cdecl(void)> && task, std::optional<std::chrono::time_point<std::chrono::steady_clock,std::chrono::duration<__int64,std::ratio<1,1000000000>>>> endTime) Line 208 C++
Microsoft.ReactNative.dll!Mso::LooperScheduler::RunLoop(const Mso::WeakPtr<Mso::LooperScheduler> & weakSelf) Line 49 C++
Microsoft.ReactNative.dll!Mso::LooperScheduler::<lambda>() Line 36 C++
[External Code]
Please see Bug Description for details. Code sample can be provided on request [INTERNAL].
Debug builds of unpackaged Win32 React Native applications running via XAML Islands should be able to load bundles using the optimized Release build of hermes.dll.