diff --git a/Libraries/Utilities/MessageQueue.js b/Libraries/Utilities/MessageQueue.js index ffca2bca5..007b0dfca 100644 --- a/Libraries/Utilities/MessageQueue.js +++ b/Libraries/Utilities/MessageQueue.js @@ -65,13 +65,11 @@ class MessageQueue { localModules && this._genLookupTables( localModules, this._moduleTable, this._methodTable); - if (__DEV__) { - this._debugInfo = {}; - this._remoteModuleTable = {}; - this._remoteMethodTable = {}; - this._genLookupTables( - remoteModules, this._remoteModuleTable, this._remoteMethodTable); - } + this._debugInfo = {}; + this._remoteModuleTable = {}; + this._remoteMethodTable = {}; + this._genLookupTables( + remoteModules, this._remoteModuleTable, this._remoteMethodTable); } /** @@ -116,13 +114,11 @@ class MessageQueue { */ __nativeCall(module, method, params, onFail, onSucc) { if (onFail || onSucc) { - if (__DEV__) { - // eventually delete old debug info - (this._callbackID > (1 << 5)) && - (this._debugInfo[this._callbackID >> 5] = null); + // eventually delete old debug info + (this._callbackID > (1 << 5)) && + (this._debugInfo[this._callbackID >> 5] = null); - this._debugInfo[this._callbackID >> 1] = [module, method]; - } + this._debugInfo[this._callbackID >> 1] = [module, method]; onFail && params.push(this._callbackID); this._callbacks[this._callbackID++] = onFail; onSucc && params.push(this._callbackID); @@ -155,13 +151,15 @@ class MessageQueue { BridgeProfiling.profile( () => `MessageQueue.invokeCallback(${cbID}, ${stringifySafe(args)})`); let callback = this._callbacks[cbID]; - if (__DEV__) { + if (!callback || __DEV__) { let debug = this._debugInfo[cbID >> 1]; let module = debug && this._remoteModuleTable[debug[0]]; let method = debug && this._remoteMethodTable[debug[0]][debug[1]]; - if (!callback) { - console.error(`Callback with id ${cbID}: ${module}.${method}() not found`); - } else if (SPY_MODE) { + invariant( + callback, + `Callback with id ${cbID}: ${module}.${method}() not found` + ); + if (callback && SPY_MODE) { console.log('N->JS : (' + JSON.stringify(args) + ')'); } }