Ionic-framework: Android back button: "EXCEPTION: Uncaught (in promise): false" when ionViewCanLeave() returns false

Created on 11 Feb 2017  路  5Comments  路  Source: ionic-team/ionic-framework

Ionic version: (check one with "x")
[x] 2.x

I'm submitting a ... (check one with "x")
[x] bug report

Current behavior:
On Android, when you push a new view in the navigation stack (either through navCtrl.push() or by presenting a modal), then on that view you use ionViewCanLeave() to control if the view can be closed, then use the device back button to exit the view and ionViewCanLeave() disallows exiting the view by returning false, a "EXCEPTION: Uncaught (in promise): false" error is thrown with the following stack trace:

error_handler.js:53 Error: Uncaught (in promise): false
    at s (polyfills.js:3)
    at polyfills.js:3
    at Object.ti.reject (nav-controller-base.js:187)
    at NavControllerBase._viewTest (nav-controller-base.js:438)
    at NavControllerBase._nextTrns (nav-controller-base.js:244)
    at NavControllerBase._queueTrns (nav-controller-base.js:208)
    at NavControllerBase.pop (nav-controller-base.js:73)
    at recursivePop (app.js:241)
    at App.navPop (app.js:218)
    at App.goBack (app.js:193)

Expected behavior:
When ionViewCanLeave() returns false and navCtrl.pop() is called internally by the framework when pressing the device back button, a catch() should be made internally on the pop() call to prevent this uncaught promise exception.

Steps to reproduce:
Here's the plunker: http://plnkr.co/edit/Gt0XSaRxFPEmwtZXnz9b

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

Cordova CLI: 6.5.0 
Ionic Framework Version: 2.0.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.0.0
ios-deploy version: 1.9.0 
ios-sim version: 5.0.13 
OS: OS X Mavericks
Node Version: v6.2.0
Xcode version: Xcode 6.2 Build version 6C131e

All 5 comments

+1

Hello, I am going to close this issue as a duplicate of https://github.com/driftyco/ionic/issues/10194

I am still facing issues with this. I have a modal with ionViewCanLeave guard.

  ionViewCanLeave(){
    this.goBack();
    return false;
  }

returns the same error mentioned in the issue.

Second thoughts, I guess its better to handle it with back button action,

    this.platform.registerBackButtonAction( () => {
      console.log('back');
        this.goBack();
     },10)

@jgw96 Please reopen this issue as https://github.com/driftyco/ionic/issues/10194 does not fix this issue.

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danbucholtz picture danbucholtz  路  3Comments

giammaleoni picture giammaleoni  路  3Comments

brandyscarney picture brandyscarney  路  3Comments

BilelKrichen picture BilelKrichen  路  3Comments

vswarte picture vswarte  路  3Comments