From 8ecf3972f64568b8f483005571a6b7ee44c7a1de Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Tue, 31 Mar 2015 14:56:10 -0700 Subject: [PATCH] [ReactNative] Remove global MutationObserver to fix Bluebird feature detection Summary: Bluebird is checking if MutationObserver exists and if it does, uses it and instant crashes. Since we don't have the DOM, MutationObserver doesn't make sense. Also, pretty cool thing, the bluebird maintainer updated the feature detection to fallback to setImmediate before checking setTimeout. He committed and made a new version in less than 5 minutes! https://github.com/facebook/react-native/issues/335#issuecomment-87127803 Test Plan: Run bluebird and make sure it runs with setImmediate --- .../Initialization/InitializeJavaScriptAppEngine.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js b/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js index a9e06a6cfcbb31..51f6809ccd9b28 100644 --- a/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js +++ b/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js @@ -60,6 +60,10 @@ function setupDocumentShim() { if (GLOBAL.document) { GLOBAL.document.createElement = null; } + + // There is no DOM so MutationObserver doesn't make sense. It is used + // as feature detection in Bluebird Promise implementation + GLOBAL.MutationObserver = undefined; } function handleErrorWithRedBox(e) {