lundi 9 mars 2020

How may a defined function be undefined?

Got a mysterious error trapped when running a javascript program in the browser. I did not expect this would be possible.

  1. This is the Firefox console message when the execution was interrupted. Tne triggering code line is indicated:
TypeError: saveOrderFunc(...) is undefinedmish-project-9e3368b0606d05c921e4bcce069c6187.js:6233:24 (<***)
    doFindText http://localhost:3000/assets/mish-project-9e3368b0606d05c921e4bcce069c6187.js:6233
    invoke http://localhost:3000/assets/vendor-2ec1510f3a7e6a9956d317f82db731b5.js:66502
    flush http://localhost:3000/assets/vendor-2ec1510f3a7e6a9956d317f82db731b5.js:66392
    flush http://localhost:3000/assets/vendor-2ec1510f3a7e6a9956d317f82db731b5.js:66601
    _end http://localhost:3000/assets/vendor-2ec1510f3a7e6a9956d317f82db731b5.js:67177
    end http://localhost:3000/assets/vendor-2ec1510f3a7e6a9956d317f82db731b5.js:66863
    _runExpiredTimers http://localhost:3000/assets/vendor-2ec1510f3a7e6a9956d317f82db731b5.js:67314
    _runExpiredTimers self-hosted:874
  1. Here is the program code as presented by the Firefox code debug listing with the triggering code line indicated, when the execution was interrupted:
...
var saveOrderFunc = function saveOrderFunc(namelist) {
  return new Ember.RSVP.Promise(function (resolve, reject) {
    (0, _jquery.default)("#sortOrder").text(namelist);
    var IMDB_DIR = (0, _jquery.default)('#imdbDir').text();
    var xhr = new XMLHttpRequest();
    xhr.open('POST', 'saveorder/' + IMDB_DIR);
    xhr.onload = function () {
      if (this.status >= 200 && this.status < 300) {
        userLog("SAVE");
        resolve(true);
      } else {
        userLog("SAVE error");
        reject({
          status: this.status,
          statusText: xhr.statusText
        });
      }
    };
    xhr.send(namelist);
  }).catch(function (error) {
    console.error(error.message);
  });
};
Ember.run.later(function () {
  saveOrderFunc(nameOrder.trim()).then(function () {   //  (<***)
    if (n && n <= 100 && loginStatus === "guest") {
      Ember.run.later(function () {
        (0, _jquery.default)("div[aria-describedby='dialog'] button#yesBut").click();
      }, 20);
    }

  });
}, 400);
...

May this be an Ember system bug, or what's up?

$ ember -v ember-cli: 3.11.0 node: 8.17.0 os: linux x64

Why so old Ember? Have to upgrade Node first. Why so old Node? Several dependent packages are still lagging; postponed the next upgrade a few months.




Aucun commentaire:

Enregistrer un commentaire