2

I am trying to import an Apps Script library into App Maker as outlined in this page: https://developers.google.com/appmaker/scripting/libraries

However, after successfully importing it into the App Maker app, upon trying to use the library within a server script (typing in "TestLibrary.", normally when autocomplete would appear), it immediately errors with the message "Unexpected client error" in a snackbar and a popup "Refresh Required".

It is important to note that the library contains many functions, each with a JSDoc comment. However, in testing, I've found that many of them don't cause App Maker to crash in isolation. My conclusion is that it's not JSDoc comments in general that is causing App Maker to crash, but rather something to do specifically with certain ones.

I attach an example of an offending function which does cause App Maker to exhibit the described behavior.

If the JSDoc comments are removed, then the function works without issue. If the JSDoc comments are left in the library source code, then the error appears as described.

Perplexingly enough, if the library is imported into another Apps Script project, rather than an App Maker app, then it will function fully as expected, JSDoc comments intact or not.

The above research leads me to believe that the issue lies within the JSDoc parsing engine used by App Maker to provide autocomplete suggestions, since:

  1. The issue doesn't appear on the initial library adding to the app.
  2. The issue only appears immediately when autocomplete would normally appear.
  3. The issue only appears if (certain) JSDoc comments are present.
  4. The issue never appears trying to use the library in another Apps Script project.

I've published a sample library with the ID 1KSnHTkbPnzxFuiX-QuDqVYGoLjCLXNaNwePmPZFDE63lVPN3GvKHDr_j. - Version 1 has the JSDoc intact, exhibiting the issue. - Version 2 is the exact same function but without the JSDoc. No issue.

/**
 * Remove the first element of an array with a given value.
 *
 * Last updated: 2019-06-29
 *
 * Example 1. Input { [1,2,3,4,3,2,1] , 3   } returns { [1,2,4,3,2,1]   }.
 * Example 2. Input { [1,2,3,4,3,2,1] , 5   } returns { [1,2,3,4,3,2,1] }.
 * Example 3. Input { [1,2,3,4,3,2,1] , "3" } returns { [1,2,3,4,3,2,1] }.
 *
 * @author  My Name <my@email.address>
 * @param   {Object[]}         arr  - Array of strings or numbers (can be mixed).
 * @param   {(String|Number)}  val  - Value to remove from the array.
 * @return  {Object[]}              - Array with the selected value removed, if any.
 *
 */
function Arrays_removeElementOfValue(arr, val) {
  var index = arr.indexOf(val);
  if (index > -1) {
    arr.splice(index, 1); // splice removes n element(s) in-place from an array; in this case, 1
  }

  return arr;
}

I would expect that the library is able to be used within App Maker without having to strip the JSDoc comments out.

The error I receive is not helpful, other than

"Generic client error" and "Refresh Required".

Graham P Heath
  • 7,009
  • 3
  • 31
  • 45
James
  • 153
  • 9

0 Answers0