Fixed infinite #clowntown error loop
This commit is contained in:
parent
766983f69b
commit
7c3070628a
|
@ -48,8 +48,10 @@ function reportException(e: Exception, isFatal: bool, stack?: any) {
|
||||||
var prettyStack = parseErrorStack(e, map);
|
var prettyStack = parseErrorStack(e, map);
|
||||||
RCTExceptionsManager.updateExceptionMessage(e.message, prettyStack);
|
RCTExceptionsManager.updateExceptionMessage(e.message, prettyStack);
|
||||||
})
|
})
|
||||||
.then(null, error => {
|
.catch(error => {
|
||||||
console.error('#CLOWNTOWN (error while displaying error): ' + error.message);
|
// This can happen in a variety of normal situations, such as
|
||||||
|
// Network module not being available, or when running locally
|
||||||
|
console.warn('Unable to load source map: ' + error.message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,13 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var Promise = require('Promise');
|
var Promise = require('Promise');
|
||||||
var RCTSourceCode = require('NativeModules').SourceCode;
|
var NativeModules = require('NativeModules');
|
||||||
var SourceMapConsumer = require('SourceMap').SourceMapConsumer;
|
var SourceMapConsumer = require('SourceMap').SourceMapConsumer;
|
||||||
var SourceMapURL = require('./source-map-url');
|
var SourceMapURL = require('./source-map-url');
|
||||||
|
|
||||||
|
var RCTSourceCode = NativeModules.SourceCode;
|
||||||
|
var RCTDataManager = NativeModules.DataManager;
|
||||||
|
|
||||||
function loadSourceMap(): Promise {
|
function loadSourceMap(): Promise {
|
||||||
return fetchSourceMap()
|
return fetchSourceMap()
|
||||||
.then(map => new SourceMapConsumer(map));
|
.then(map => new SourceMapConsumer(map));
|
||||||
|
@ -31,17 +34,31 @@ function fetchSourceMap(): Promise {
|
||||||
return Promise.reject(new Error('RCTSourceCode module is not available'));
|
return Promise.reject(new Error('RCTSourceCode module is not available'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!RCTDataManager) {
|
||||||
|
// Used internally by fetch
|
||||||
|
return Promise.reject(new Error('RCTDataManager module is not available'));
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise(RCTSourceCode.getScriptText)
|
return new Promise(RCTSourceCode.getScriptText)
|
||||||
.then(extractSourceMapURL)
|
.then(extractSourceMapURL)
|
||||||
|
.then((url) => {
|
||||||
|
if (url === null) {
|
||||||
|
return Promise.reject(new Error('No source map URL found. May be running from bundled file.'));
|
||||||
|
}
|
||||||
|
return Promise.resolve(url);
|
||||||
|
})
|
||||||
.then(fetch)
|
.then(fetch)
|
||||||
.then(response => response.text())
|
.then(response => response.text())
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractSourceMapURL({url, text, fullSourceMappingURL}): string {
|
function extractSourceMapURL({url, text, fullSourceMappingURL}): ?string {
|
||||||
if (fullSourceMappingURL) {
|
if (fullSourceMappingURL) {
|
||||||
return fullSourceMappingURL;
|
return fullSourceMappingURL;
|
||||||
}
|
}
|
||||||
var mapURL = SourceMapURL.getFrom(text);
|
var mapURL = SourceMapURL.getFrom(text);
|
||||||
|
if (!mapURL) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
var baseURL = url.match(/(.+:\/\/.*?)\//)[1];
|
var baseURL = url.match(/(.+:\/\/.*?)\//)[1];
|
||||||
return baseURL + mapURL;
|
return baseURL + mapURL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue