Are JS Generator functions disallowed in Macros?

Hello,

I recently wanted to use a generator function inside of a macro to encapsulate some iteration logic on a spreadsheet, and make it easily copy-paste-able from one macro to another.

However, the macro did not work, after a closer inspection by opening the browser console in a web editor, I saw errors every time I ran the macro: “TypeError: next() function returned undefined”. Inspecting the generator object itself I saw the next method was modified and referred to an empty function in a file called sdkjs-all.min.js in an onlyoffice path.

I reproduced a minimal test file in a desktop editor with the same issue. The excel file with the OO macro can be found here: https://docs.google.com/spreadsheets/d/1qgMriRKJo4X292mmxU-D2JaQpmvcP_0B/edit?usp=sharing&ouid=103710046280902230937&rtpof=true&sd=true (Hoping it can be downloaded without issues)

The nature of the failure seems to indicate it was intentional, so the question is, to confirm: Is it intentional that generator functions do not work in macros ? If so what would be the reasons behind the decision ?

For additional more technical details:

The failure is that onlyoffice code overwrites the generator’s prototype’s next method with an empty function, which could look like something like this in code:

(function*(){}).constructor.prototype.prototype.next = function(){};

Hi @thetos :wave:

I’m currently looking into the details and will get back to you soon with an update.

1 Like