question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Failed to execute 'construct' on 'CustomElementConstructor'

See original GitHub issue

Bug Report

Ionic version:

[x] 4.11.10

Current behavior:

I’m experiencing an exception when using local notifications in an ionic native application. The exception only happens sometimes and I was not able to come up with exact reproduction steps. I wanted to open this bug because maybe someone can help me to point to the right direction so I can come up with exact reproduction steps for this ionic bug.

Basically what happens is that the user receives a notification (while app is in foreground) and then he sends the app to background. After waiting for like 10-30mins he clicks on the notification (while the app is still in background; so not a cold start). By clicking on the notification we trigger a navigation command navigateForward which produces the following exception: Uncaught Error: Failed to execute 'construct' on 'CustomElementConstructor': The provided callback is no longer runnable.:

Screenshot 2020-03-06 at 09 37 22 Screenshot 2020-03-06 at 09 40 23

Expected behavior:

No exception is happening.

Steps to reproduce:

No clear reproduction steps available unfortunately. We were able to reproduce this bug mostly when app got sent to background for about 10-30mins & the phone screen got locked before clicking on the notification.

Related code:

In app.component:

async ngOnInit() {
    await this.platform.ready();
    // Omitted code to simplify example

    this.localNotifications.on('click').subscribe(async (not: ILocalNotification) => {
        // Omitted code to simplify example
        await this.zone.run(async () => {
            // ON NEXT LINE THE EXCEPTION HAPPENS
            await this.navCtrl.navigateForward([AppRoutes.CHAT + '/' + not.data.chat.type + '/' + not.data.chat.id], { animated: false }); 
        });
    });
}

Other information:

EDIT 1: I found this bug https://github.com/ionic-team/ionic/issues/17411 and tried to verify whether the bug is still happening with the mentioned fix. Unfourtunatly the bug was still reproducable in the following scenarios:

  • With only es5
  • With differential loading (es5 + es2015)
  • Without differential building only es2015

EDIT 2: Linking this issue to https://github.com/ionic-team/ionic/issues/20721 as they are related (both happens in the same scenario).

Ionic info:

Ionic:

   Ionic CLI                     : 6.2.0 (/Users/borntraegermarc/.nvm/versions/node/v12.13.0/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 4.11.10
   @angular-devkit/build-angular : 0.803.23
   @angular-devkit/schematics    : 8.3.23
   @angular/cli                  : 8.3.23
   @ionic/angular-toolkit        : 2.1.2

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.1.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 24 other plugins)

Utility:

   cordova-res : not installed
   native-run  : 0.3.0

System:

   ios-sim : 8.0.2
   NodeJS  : v12.13.0 (/Users/borntraegermarc/.nvm/versions/node/v12.13.0/bin/node)
   npm     : 6.14.2
   OS      : macOS Catalina
   Xcode   : Xcode 10.3 Build version 10G8

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
BorntraegerMarccommented, Mar 31, 2020

Wow! I can only imagine how painful it must have been to debug & come up with this workaround 😄 Thanks a lot!

Can you give this workaround a try and let me know if it resolves the issue? I imagine this workaround can be used for #20721 as well.

Indeed it resolves both these issues. Even in our very complex production app!

There must be something that the OS is doing to the webview when the app is in the background for longer than a certain period of time.

Hmmm… Do you think we should maybe open a bug for the android webview? To verify that this behaviour is expected. Or would you say it’s generally in the responsibilities of cordova / capacitor plugins to await the resume event?

1reaction
BorntraegerMarccommented, Mar 30, 2020

@duncan-c yeah, I’d say it’s the same bug. How a notification is generated and the “click” event is triggered probably doesn’t make a big difference. Also whether navigate or navigateForward is used doesn’t make a difference (it’s basically the same).

Read more comments on GitHub >

github_iconTop Results From Across the Web

bug: Failed to execute 'construct' on ... - GitHub
Current behavior: I'm experiencing an exception when using local notifications in an ionic native application. The exception only happens ...
Read more >
Deferred setAttribute call in Custom Element constructor ...
Deferred setAttribute call in Custom Element constructor causes DOM error. Is it a bug? Ask Question. Asked 3 years, 9 months ago. Modified...
Read more >
Failed to execute 'construct' on 'CustomElementConstructor'
Basically what happens is that the user receives a notification (while app is in foreground) and then he sends the app to background....
Read more >
Custom Elements - W3C
The " failed " state is used to ensure that if a custom element constructor fails to execute correctly the first time, it...
Read more >
Failed to execute 'construct' on 'CustomElementConstructor'
Uncaught Error: Failed to execute 'construct' on 'CustomElementConstructor': The provided callback is no longer runnable. at ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found