Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maximum number of scopes exceeded #948

Closed
gfwilliams opened this issue Oct 14, 2016 · 9 comments
Closed

Maximum number of scopes exceeded #948

gfwilliams opened this issue Oct 14, 2016 · 9 comments

Comments

@gfwilliams
Copy link
Member

With callbacks hell it's actually pretty easy:

function go() {
 setTimeout(function() {
  setTimeout(function() {
   setTimeout(function() {
    setTimeout(function() {
     setTimeout(function() {
      setTimeout(function() {
       setTimeout(function() {
        setTimeout(function() {
         setTimeout(function() {
          result = 1;
         }, 10);
        }, 10);
       }, 10);
      }, 10);
     }, 10);
    }, 10);
   }, 10);
  }, 10);
 }, 10);
}

go();

Ideally we should use a JS array for scopes to avoid the hard limit

@vshymanskyy
Copy link
Contributor

Ok, I was actually able to get async/await working on Espruino (using Babel transpiler and some hacking). Here is a full example: https://github.com/vshymanskyy/espruino-await

The uglify module sometimes inlines and chains functions and Promises (with some minification options) and I have started facing this issue. Had to disable some optimizations.

@gfwilliams
Copy link
Member Author

It's been hit again here: http://forum.espruino.com/conversations/332111/#comment14671765

@gfwilliams
Copy link
Member Author

Just to add, I have a workable solution to this which doesn't impose any limits. Just debugging some memory leaks and it'll be sorted

@zored
Copy link

zored commented Jun 7, 2020

Is there any way to increase this limit? I went too far with my async/await calls and now there is no way back 😂

@gfwilliams
Copy link
Member Author

How are you using async/await? A transpiler?

You could build your own firmware with this changed I believe?

#define JSPARSE_MAX_SCOPES 8

@zored
Copy link

zored commented Jun 9, 2020

@gfwilliams thank you a lot for this reference! Yes, I use fast-async babel transformer mentioned above.

Generally I'm transpiling TypeScript. Despite some callbacks overhead it works great.

@opichals
Copy link
Contributor

opichals commented Jun 9, 2020

@gfwilliams Maybe I am missing something but it looks like this limitation should have been dropped since Mar 2019.

https://github.com/espruino/Espruino/search?q=JSPARSE_MAX_SCOPES doesn't find any use of the JSPARSE_MAX_SCOPES define.

@gfwilliams
Copy link
Member Author

That's a very good point - I'll remove that define.

@zored looks like you're just using a really out of date firmware then?

@zored
Copy link

zored commented Jun 9, 2020

@gfwilliams That's right! We have a board called Iskra JS (like "Spark JS") in Russia and its firmware is based on some really outdated version of Espruino. I will try to keep it up to date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants