[TIMOB-25883] "Callback was already called." error thrown when source contains syntax error and transpiling
| GitHub Issue | n/a | 
|---|---|
| Type | Bug | 
| Priority | High | 
| Status | Closed | 
| Resolution | Fixed | 
| Resolution Date | 2018-05-01T13:38:07.000+0000 | 
| Affected Version/s | Release 7.1.0, Hyperloop 3.1.0 | 
| Fix Version/s | Release 7.3.0 | 
| Components | Hyperloop, iOS | 
| Labels | async.js, hyperloop, ios | 
| Reporter | Hans Knöchel | 
| Assignee | Christopher Williams | 
| Created | 2018-03-19T18:42:23.000+0000 | 
| Updated | 2018-07-11T22:43:39.000+0000 | 
Description
	(Only seen on iOS)
When trying to build our hyperloop-examples sample app, the 
Callback was already called. error is thrown. It seems to be an issue thrown from the async library we use. There are [reports](https://stackoverflow.com/a/27521528/5537752) that see this happening when errors are not guarded inside parallel callback flows, so thats where we need to dig into it. 
*EDIT*:
Here is a log:
[DEBUG] Copying and minifying /Users/hknoechel/Documents/Apps/hyperloop-examples/Resources/iphone/alloy/controllers/BaseController.js => /Users/hknoechel/Documents/Apps/hyperloop-examples/build/iphone/build/Products/Debug-iphonesimulator/Hyperloop_Sample.app/alloy/controllers/BaseController.js
[TRACE] Checking require for: /alloy
[TRACE] Checking import for: uikit/uialertcontroller
[TRACE] Checking import for: uikit/uialertaction
[TRACE] Checking import for: uikit/uikit
[TRACE] Checking import for: titanium/tiapp
[DEBUG] Writing /Users/hknoechel/Documents/Apps/hyperloop-examples/build/iphone/build/Products/Debug-iphonesimulator/Hyperloop_Sample.app/alloy/controllers/alert.js
[DEBUG] Copying and minifying /Users/hknoechel/Documents/Apps/hyperloop-examples/Resources/iphone/alloy/controllers/alert.js => /Users/hknoechel/Documents/Apps/hyperloop-examples/build/iphone/build/Products/Debug-iphonesimulator/Hyperloop_Sample.app/alloy/controllers/alert.js
[TRACE] Checking require for: /alloy
[TRACE] Checking import for: uikit/uiview
[TRACE] Checking import for: uikit/uicolor
[TRACE] Checking import for: coregraphics/coregraphics
[DEBUG] Writing /Users/hknoechel/Documents/Apps/hyperloop-examples/build/iphone/build/Products/Debug-iphonesimulator/Hyperloop_Sample.app/alloy/controllers/animateview.js
[DEBUG] Copying and minifying /Users/hknoechel/Documents/Apps/hyperloop-examples/Resources/iphone/alloy/controllers/animateview.js => /Users/hknoechel/Documents/Apps/hyperloop-examples/build/iphone/build/Products/Debug-iphonesimulator/Hyperloop_Sample.app/alloy/controllers/animateview.js
[TRACE] Checking require for: /alloy
[TRACE] Checking import for: uikit/uilabel
[TRACE] Checking import for: uikit/uicolor
[TRACE] Checking import for: uikit/uiscreen
[TRACE] Checking import for: uikit/uiview
[TRACE] Checking import for: uikit/nslayoutconstraint
[TRACE] Checking import for: uikit/uikit
[DEBUG] Writing /Users/hknoechel/Documents/Apps/hyperloop-examples/build/iphone/build/Products/Debug-iphonesimulator/Hyperloop_Sample.app/alloy/controllers/autolayout.js
[DEBUG] Copying and minifying /Users/hknoechel/Documents/Apps/hyperloop-examples/Resources/iphone/alloy/controllers/autolayout.js => /Users/hknoechel/Documents/Apps/hyperloop-examples/build/iphone/build/Products/Debug-iphonesimulator/Hyperloop_Sample.app/alloy/controllers/autolayout.js
[TRACE] Checking require for: /alloy
[TRACE] Checking import for: corelocation/clbeaconregion
[TRACE] Checking import for: corelocation/cllocationmanager
[TRACE] Checking import for: corelocation/corelocation
[TRACE] Checking import for: uikit/uiapplication
[TRACE] Checking import for: uikit/uilocalnotification
[TRACE] Checking import for: foundation/nsuuid
[TRACE] Checking require for: subclasses/locationmanagerdelegate
[DEBUG] Writing /Users/hknoechel/Documents/Apps/hyperloop-examples/build/iphone/build/Products/Debug-iphonesimulator/Hyperloop_Sample.app/alloy/controllers/beacons.js
[DEBUG] Copying and minifying /Users/hknoechel/Documents/Apps/hyperloop-examples/Resources/iphone/alloy/controllers/beacons.js => /Users/hknoechel/Documents/Apps/hyperloop-examples/build/iphone/build/Products/Debug-iphonesimulator/Hyperloop_Sample.app/alloy/controllers/beacons.js
[TRACE] Checking require for: /alloy
[TRACE] Checking import for: uikit/uiview
[TRACE] Checking import for: uikit/uicolor
[TRACE] Checking import for: uikit/uiblureffect
[TRACE] Checking import for: uikit/uivisualeffectview
[TRACE] Checking import for: uikit/uikit
[TRACE] Checking import for: coregraphics/coregraphics
[DEBUG] Writing /Users/hknoechel/Documents/Apps/hyperloop-examples/build/iphone/build/Products/Debug-iphonesimulator/Hyperloop_Sample.app/alloy/controllers/blur.js
[ERROR] Callback was already called.
const vs. let issue! I remember the compiler detects that different, so maybe its handled different when being used in Hyperloop code? Maybe we need to return somewhere in order to handle the error in a different layer. Lowing the priority ...
Example:
const screenRect = UIScreen.mainScreen.bounds;
screenRect = CGRectMake(0, 0, UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height - 64);
https://github.com/appcelerator/titanium_mobile/pull/9969
Test-Case: 1. Create new app 2. Add the following at the top (or anywhere else) in your code:
Expected behavior: The build should fail with the error: "a" is read-only.Verified fixed and changes are in SDKs 7.3.0.v20180711122153 & 7.4.0.v20180711095209