Skip to content

Commit 7c30706

Browse files
committed
Fixed infinite #clowntown error loop
1 parent 766983f commit 7c30706

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

Libraries/JavaScriptAppEngine/Initialization/ExceptionsManager.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ function reportException(e: Exception, isFatal: bool, stack?: any) {
4848
var prettyStack = parseErrorStack(e, map);
4949
RCTExceptionsManager.updateExceptionMessage(e.message, prettyStack);
5050
})
51-
.then(null, error => {
52-
console.error('#CLOWNTOWN (error while displaying error): ' + error.message);
51+
.catch(error => {
52+
// This can happen in a variety of normal situations, such as
53+
// Network module not being available, or when running locally
54+
console.warn('Unable to load source map: ' + error.message);
5355
});
5456
}
5557
}

Libraries/JavaScriptAppEngine/Initialization/loadSourceMap.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313
'use strict';
1414

1515
var Promise = require('Promise');
16-
var RCTSourceCode = require('NativeModules').SourceCode;
16+
var NativeModules = require('NativeModules');
1717
var SourceMapConsumer = require('SourceMap').SourceMapConsumer;
1818
var SourceMapURL = require('./source-map-url');
1919

20+
var RCTSourceCode = NativeModules.SourceCode;
21+
var RCTDataManager = NativeModules.DataManager;
22+
2023
function loadSourceMap(): Promise {
2124
return fetchSourceMap()
2225
.then(map => new SourceMapConsumer(map));
@@ -31,17 +34,31 @@ function fetchSourceMap(): Promise {
3134
return Promise.reject(new Error('RCTSourceCode module is not available'));
3235
}
3336

37+
if (!RCTDataManager) {
38+
// Used internally by fetch
39+
return Promise.reject(new Error('RCTDataManager module is not available'));
40+
}
41+
3442
return new Promise(RCTSourceCode.getScriptText)
3543
.then(extractSourceMapURL)
44+
.then((url) => {
45+
if (url === null) {
46+
return Promise.reject(new Error('No source map URL found. May be running from bundled file.'));
47+
}
48+
return Promise.resolve(url);
49+
})
3650
.then(fetch)
3751
.then(response => response.text())
3852
}
3953

40-
function extractSourceMapURL({url, text, fullSourceMappingURL}): string {
54+
function extractSourceMapURL({url, text, fullSourceMappingURL}): ?string {
4155
if (fullSourceMappingURL) {
4256
return fullSourceMappingURL;
4357
}
4458
var mapURL = SourceMapURL.getFrom(text);
59+
if (!mapURL) {
60+
return null;
61+
}
4562
var baseURL = url.match(/(.+:\/\/.*?)\//)[1];
4663
return baseURL + mapURL;
4764
}

0 commit comments

Comments
 (0)