yandex / mapsapi-modules

Async modular system
132 stars 29 forks source link

Prevent 'too much recursion' error in FF@linux #52

Closed h4 closed 3 years ago

h4 commented 8 years ago

This summer we got error 'too much recursion' in our project that uses bem-core.

This error happens only in Firefox under linux (yeah, Ubuntu) and only if we have lot modules in one file (~200 in our case).

Delay applying declarations with wrap in nextTick fix this problem (this solution was found in https://github.com/pouchdb/pouchdb/issues/1156#issuecomment-31136504).

dfilatov commented 8 years ago

Likely it fixes your problem but this solution makes every declaration execution asynchronous what may lead to unsuitable delay for long dependency path. We have more than thousand declarations in one file and never encountered such a problem. Maybe better to report problem to FF team? Especially as it happens only in FF@linux.

dfilatov commented 8 years ago

I'll try to find FF@linux and run pure test with a huge number of modules.

korotovsky commented 8 years ago

@dfilatov ping

dfilatov commented 8 years ago

@korotovsky Could you try out the following code?

var MODULES_COUNT = 1000;
for(var i = 0; i < MODULES_COUNT; i++) {
    modules.define('module' + i, i > 0? ['module' + (i - 1)] : [], function(provide) {
        provide(this.name);
    });
}
modules.require('module' + (MODULES_COUNT - 1), function(module) {
    console.log(module + ' resolved');
});