Skip to content

Commit acd1a6c

Browse files
Merge pull request #615 from Instabug/release/10.8.1
2 parents d39165f + c718728 commit acd1a6c

File tree

8 files changed

+49
-9
lines changed

8 files changed

+49
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## v10.8.1 (2021-08-25)
2+
3+
* Fixes a crash that occurs with network requests on slow network connectivity in v10.8
4+
* Fixes an issue with parseErrorStack whose signature was changed on RN 0.64
5+
16
## v10.8.0 (2021-08-04)
27

38
* Bumps Instabug native SDKs to v10.8

InstabugSample/ios/Podfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ target 'InstabugSample' do
2828
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
2929
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
3030

31+
post_install do |installer|
32+
## Fix for XCode 12.5 beta
33+
find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
34+
"_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
35+
end
36+
3137
target 'InstabugSampleTests' do
3238
inherit! :search_paths
3339
# Pods for testing
@@ -36,3 +42,17 @@ target 'InstabugSample' do
3642

3743
use_native_modules!
3844
end
45+
46+
def find_and_replace(dir, findstr, replacestr)
47+
Dir[dir].each do |name|
48+
text = File.read(name)
49+
replace = text.gsub(findstr,replacestr)
50+
if text != replace
51+
puts "Fix: " + name
52+
File.open(name, "w") { |file| file.puts replace }
53+
STDOUT.flush
54+
end
55+
end
56+
Dir[dir + '*/'].each(&method(:find_and_replace))
57+
end
58+

__tests__/crashReporting.spec.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ describe('CrashReporting Module', () => {
4444
it('should call the native method sendHandledJSCrash when platform is ios', () => {
4545

4646
Platform.OS = 'ios';
47-
InstabugUtils.parseErrorStack.mockImplementation(() => 'javascriptStackTrace');
4847
const errorObject = { name: 'TypeError', message: 'Invalid type' };
4948
CrashReporting.reportJSException(errorObject);
5049

@@ -62,7 +61,6 @@ describe('CrashReporting Module', () => {
6261
it('should call the native method sendHandledJSCrash when platform is android', () => {
6362

6463
Platform.OS = 'android';
65-
InstabugUtils.parseErrorStack.mockImplementation(() => 'javascriptStackTrace');
6664
const errorObject = { name: 'TypeError', message: 'Invalid type' };
6765
CrashReporting.reportJSException(errorObject);
6866

@@ -81,7 +79,6 @@ describe('CrashReporting Module', () => {
8179
it('should emit event IBGSendHandledJSCrash with the error object when platform is android', (done) => {
8280

8381
Platform.OS = 'android';
84-
InstabugUtils.parseErrorStack.mockImplementation(() => 'javascriptStackTrace');
8582
InstabugUtils.isOnReportHandlerSet.mockImplementation(() => true);
8683

8784
const errorObject = { name: 'TypeError', message: 'Invalid type' };

jest/mockInstabugUtils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ jest.mock('../utils/InstabugUtils', () => {
44
captureJsErrors: jest.fn(),
55
setOnReportHandler: jest.fn(),
66
isOnReportHandlerSet: jest.fn(),
7-
getActiveRouteName: jest.fn()
7+
getActiveRouteName: jest.fn(),
8+
getStackTrace: jest.fn(() => 'javascriptStackTrace')
89
}
910
});

modules/CrashReporting.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export default {
2424
* @param errorObject Error object to be sent to Instabug's servers
2525
*/
2626
reportJSException: function(errorObject) {
27-
let jsStackTrace = InstabugUtils.parseErrorStack(errorObject);
27+
let jsStackTrace = InstabugUtils.getStackTrace(errorObject);
28+
2829
var jsonObject = {
2930
message: errorObject.name + ' - ' + errorObject.message,
3031
os: Platform.OS,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "instabug-reactnative",
3-
"version": "10.8.0",
3+
"version": "10.8.1",
44
"description": "React Native plugin for integrating the Instabug SDK",
55
"main": "index.js",
66
"types": "index.d.ts",

utils/InstabugUtils.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,21 @@ function getFullRoute(state) {
4040
}
4141
}
4242

43+
export const getStackTrace = (e) => {
44+
let jsStackTrace;
45+
if (Platform.hasOwnProperty("constants")) {
46+
// RN version >= 0.63
47+
if (Platform.constants.reactNativeVersion.minor >= 64)
48+
// RN version >= 0.64 -> Stacktrace as string
49+
jsStackTrace = parseErrorStackLib(e.stack);
50+
// RN version == 0.63 -> Stacktrace as string
51+
else jsStackTrace = parseErrorStackLib(e);
52+
}
53+
// RN version < 0.63 -> Stacktrace as string
54+
else jsStackTrace = parseErrorStackLib(e);
55+
return jsStackTrace;
56+
};
57+
4358
export const isOnReportHandlerSet = () => {
4459
return _isOnReportHandlerSet;
4560
};
@@ -52,7 +67,7 @@ export const captureJsErrors = () => {
5267
}
5368

5469
function errorHandler(e, isFatal) {
55-
let jsStackTrace = parseErrorStackLib(e);
70+
let jsStackTrace = getStackTrace(e);
5671

5772
//JSON object to be sent to the native SDK
5873
var jsonObject = {
@@ -91,5 +106,6 @@ export default {
91106
setOnReportHandler,
92107
isOnReportHandlerSet,
93108
getActiveRouteName,
94-
getFullRoute
109+
getFullRoute,
110+
getStackTrace,
95111
};

utils/XhrNetworkInterceptor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const XHRInterceptor = {
111111
cloneNetwork.errorCode = 0;
112112
cloneNetwork.errorDomain = 'ClientError';
113113

114-
cloneNetwork.requestBody = this._response;
114+
cloneNetwork.requestBody = typeof this._response === "string" ? this._response : JSON.stringify(this._response);
115115
cloneNetwork.responseBody = null;
116116
}
117117
if (onDoneCallback) {

0 commit comments

Comments
 (0)