UncaughtExceptionHandler is called 2 times
Natalia-Hristova opened this issue · comments
Environment
- CLI:
next
- iOS Runtime:
next
5.2.0-2019-01-08-012440-01
Describe the bug
If you try to handle uncaughtErrorEvent in the log you'll see that this event occur twice
To Reproduce
NOTE: run it on device to see the log because of this known issue with simulators
- Create project e.g ts
tns create TestApp --tsc
- In
onTap()
add crash:
public onTap() {
this._counter--;
this.updateMessage();
console.log("IOS Crash Test 1");
const foo: NSArray<any> = NSArray.alloc();
foo.objectAtIndex(3);
}
- Handle handle uncaughtErrorEvent like it is shown in the docs
- Run the app
tns run ios
and click the button
Here's the log:
CONSOLE LOG file:///app/main-view-model.js:38:20: IOS Crash Test 1
CONSOLE LOG file:///app/main-view-model.js:9:16: Uncaught Error Event: 1Error: *** -[NSArray objectAtIndex:]: method sent to an uninitialized immutable array object
***** Fatal JavaScript exception - application has been terminated. *****
Native stack trace:
1 0x1056f2628 NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool, bool)
2 0x1057209a8 NativeScript::FFICallback<NativeScript::ObjCMethodCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*)
3 0x106180024 ffi_closure_SYSV_inner
4 0x1061841b4 .Ldo_closure
5 0x18acd26c8 <redacted>
6 0x18adf38a4 <redacted>
7 0x18acd877c <redacted>
8 0x18ae0e1dc <redacted>
9 0x18ad55a48 <redacted>
10 0x18ad4a8f8 <redacted>
11 0x18ad49238 <redacted>
12 0x18b52ac0c <redacted>
13 0x18b52d1b8 <redacted>
14 0x18b526258 <redacted>
15 0x180f4b404 <redacted>
16 0x180f4ac2c <redacted>
17 0x180f4879c <redacted>
18 0x180e68da8 CFRunLoopRunSpecific
19 0x182e4b020 GSEventRunModal
20 0x18ae4978c UIApplicationMain
21 0x106184044 ffi_call_SYSV
22 0x10617f744 ffi_call_int
23 0x10617f240 ffi_call
24 0x1056bc87c NativeScript::FunctionWrapper::call(JSC::ExecState*)
25 0x10617e2e8 llint_entry
26 0x10617d744 llint_entry
27 0x10617d744 llint_entry
28 0x10617d744 llint_entry
29 0x1061761ac vmEntryToJavaScript
30 0x105f767b8 JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
31 0x10613021c JSC::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&, WTF::NakedPtr<JSC::Exception>&)
JavaScript stack trace:
1 objectAtIndex@file:///app/main-view-model.js:40:26
2 onTap@file:///app/main-view-model.js:40:26
3 notify@file:///app/tns_modules/tns-core-modules/data/observable/observable.js:107:37
4 _emit@file:///app/tns_modules/tns-core-modules/data/observable/observable.js:127:24
5 tap@file:///app/tns_modules/tns-core-modules/ui/button/button.js:216:24
6 UIApplicationMain@[native code]
7 start@file:///app/tns_modules/tns-core-modules/application/application.js:275:26
8 run@file:///app/tns_modules/tns-core-modules/application/application.js:303:10
9 anonymous@file:///app/app.js:9:16
10 evaluate@[native code]
11 moduleEvaluation@[native code]
12 promiseReactionJob@[native code]
JavaScript error:
file:///app/main-view-model.js:40:26: JS ERROR Error: *** -[NSArray objectAtIndex:]: method sent to an uninitialized immutable array object
CONSOLE LOG file:///app/main-view-model.js:9:16: Uncaught Error Event: 2Error
*** JavaScript call stack:
(
0 UIApplicationMain@[native code]
1 start@file:///app/tns_modules/tns-core-modules/application/application.js:275:26
2 run@file:///app/tns_modules/tns-core-modules/application/application.js:303:10
3 anonymous@file:///app/app.js:9:16
4 evaluate@[native code]
5 moduleEvaluation@:1:11
6 promiseReactionJob@:1:11
)
*** Terminating app due to uncaught exception 'NativeScript encountered a fatal error: Error: *** -[NSArray objectAtIndex:]: method sent to an uninitialized immutable array object
at
1 objectAtIndex@file:///app/main-view-model.js:40:26
2 onTap@file:///app/main-view-model.js:40:26
3 notify@file:///app/tns_modules/tns-core-modules/data/observable/observable.js:107:37
4 _emit@file:///app/tns_modules/tns-core-modules/data/observable/observable.js:127:24
5 tap@file:///app/tns_modules/tns-core-modules/ui/button/button.js:216:24
6 UIApplicationMain@[native code]
7 start@file:///app/tns_modules/tns-core-modules/application/application.js:275:26
8 run@file:///app/tns_modules/tns-core-modules/application/application.js:303:10
9 anonymous@file:///app/app.js:9:16
10 evaluate@[native code]
11 moduleEvaluation@[native code]
12 promiseReactionJob@[native code]
', reason: '(null)'
*** First throw call stack:
(0x180fa2d8c 0x18015c5ec 0x1056f29d8 0x1057209a8 0x106180024 0x1061841b4 0x18acd26c8 0<\M-b\M^@\M-&>
Expected behavior
UncaughtExceptionHandler to be called only once
Sample project
ErrAppTs.zip
Additional context