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

Hi @thetos :wave:

Apologies for the delayed response.

We have logged a bug for the issue related to the incorrect behavior of generator functions in macros. Unfortunately, we do not have a timeline for a fix at the moment. However, we will update you as soon as there is information about the release of a fix.

1 Like

Hello @Nikolas

Thanks for the response I am glad to hear this is a bug, and will be on the lookout for when it is fixed :).

1 Like