9 Replies Latest reply: Jul 24, 2015 5:36 AM by Bryan Sng RSS

    qlik.openApp and qlik.close

    Bryan Sng

      Hello guys,

       

      I was trying to open an App using qlik.openApp(...);

      I thought I should also do a clean up after opening using app.close();

      However later I would need to open the app again using the exact same qlik.openApp(...);

      It turns out that the later openApp command would randomly fail, do you guys have any ideas?

       

      Below is a code sample to replicate.

      I would like to point out that if I do not clean up using app.close, the entire extension has no problem.

       

      paint: function(...) {

        var config1 = {

          host: window.location.hostname,

          port: window.location.port,

          prefix: "/",

          isSecure: window.location.protocol === "https:",

          identity: '1234567890'

        };


        var app1 = qlik.openApp('myapp', config1);

        // do something here but long enough for rpc session to be successfully opened at openApp

        app1.close();

        // do something here but long enough for rpc session to be successfully closed at close



        var config2 = {

          host: window.location.hostname,

          port: window.location.port,

          prefix: "/",

          isSecure: window.location.protocol === "https:",

          identity: '9999999999'

        };


        var app2 = qlik.openApp('myapp', config); // this method will randomly fail

        app2.close(); // this method will randomly fail


        console.log(app1 == app2); // this actually return true!

      }


      The error would be:

       

      TypeError: Cannot read property 'promise' of undefined

          at client.js??1423665506275:100

          at k.$get.k.$eval (require.js?1423665506275:43)

          at k.$get.k.$apply (require.js?1423665506275:43)

          at Object.m.$apply (client.js??1423665506275:11)

          at Object.o [as openApp] (client.js??