Uploaded image for project: 'Keycloak'
  1. Keycloak
  2. KEYCLOAK-14124

TypeError: "Promise.prototype.then called on incompatible Object"

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Critical
    • Resolution: Rejected
    • Affects Version/s: 10.0.0
    • Fix Version/s: None
    • Component/s: Adapter - JavaScript
    • Labels:
      None
    • Docs QE Status:
      NEW
    • QE Status:
      NEW

      Description

      When using keycloak.js in react app (using react scripts) we get 'TypeError: "Promise.prototype.then called on incompatible Object"':

      I have testet my Code in Chrome (81.0.4044.138 (Official Build) (64-Bit)) and Firefox (68.8.0esr (64-Bit) and 76.0.1 (64-Bit)).
      Chrome and Firefox 76.0.1 (64-Bit) work just fine.
      But we also have to support the current ESR version of Firefox (which is (68.8.0esr (64-Bit)) showing the error avobe.
      IE 11 also shows a lot of errors and switching back to keycloak.js 9.0.0 fixes them.

      If i change createPromise in keycloak.js to

      function createPromise() {
                  // Need to create a native Promise which also preserves the
                  // interface of the custom promise type previously used by the API
                  var p = {
                      // setSuccess: function(result) {
                      //     p.resolve(result);
                      // },
                      //
                      // setError: function(result) {
                      //     p.reject(result);
                      // }
                  };
                  // p.promise = new KeycloakPromise(function(resolve, reject) {
                  //     p.resolve = resolve;
                  //     p.reject = reject;
                  // });
                  p.promise = new Promise(function(resolve, reject) {
                      p.resolve = resolve;
                      p.reject = reject;
                  });
                  return p;
              }
      

      and replace all occurrences of setSuccess with resolve and setError with reject, it works just fine (also in IE 11).

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                domi.topp Dominik Krüger
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: