script-lab icon indicating copy to clipboard operation
script-lab copied to clipboard

Missing `language` in imported snippet causes hang/crash.

Open AlexJerabek opened this issue 6 years ago • 3 comments

Bug Report

  • Host: Excel
  • OS: Windows 10
  • Browser: Desktop
  • Environment: Beta

Expected behavior:

Script Lab either loads or throws an error.

Actual behavior:

Script Lab hangs, and continues to do so after restarting. Side-note, the Functions run pane loads and says the snippet must be trusted before registering it.

Steps to Reproduce:

  1. Paste this code into the import snippet text box.

Screenshot

image

AlexJerabek avatar Apr 24 '19 18:04 AlexJerabek

Huh, very interesting. I can repro it, at least on desktop. Let me look into it.

Zlatkovsky avatar Apr 24 '19 20:04 Zlatkovsky

The culprit seems to be the lack of language in this code:

order: 2
id: excel-custom-functions-streaming
name: Streaming function
description: A streaming function that continuously increments the cell value.
host: EXCEL
api_set:
    CustomFunctionsRuntime: 1.1
script:
    content: |
        /** @CustomFunction 
        *  @description Increments the cell with a given amount at a specified interval in milliseconds.
        * @param amount - The amount to add to the cell value on each increment.
        * @param interval - The time in milliseconds to wait before the next increment on the cell.
        * @returns An incrementing value.
        * @streaming
        */
        function increment(amount: number, interval: number, handler: CustomFunctions.StreamingInvocation<number>): void {
          let result = 0;
          const timer = setInterval( () => {
            result += amount;
            handler.setResult(result);
          }, interval);

          handler.onCanceled = () => {
          clearInterval(timer);
          }
        }
libraries: |
    https://appsforoffice.microsoft.com/lib/1/hosted/office.js
    @types/office-js
    [email protected]/client/core.min.js

Zlatkovsky avatar Apr 24 '19 20:04 Zlatkovsky

Should be partially addressed via: #723

However, Script Lab should do basic validation on imported data before consuming it.

wandyezj avatar Apr 05 '24 18:04 wandyezj