emmetio / sublime-tern

TernJS plugin for Sublime Text
222 stars 13 forks source link

Maximum call stack size exceeded #5

Closed webuniverseio closed 11 years ago

webuniverseio commented 11 years ago

On sublime start-up I get following error from ternjs (version: 3022 windows x64 channel: dev)


TernJS: No need to update PyV8 Syncing project D:\78Digital_projects\alliance\contests\eone-tarantino\eone-tarantino.sublime-project Staring TernJS server for D:\78Digital_projects\alliance\contests\eone-tarantino\eone-tarantino.sublime-project with 1 libs and 45 files Traceback (most recent call last): File "D:\Program Files\Sublime Text 3\sublime_plugin.py", line 156, in on_api_ready m.plugin_loaded() File "D:\Program Files\Sublime Text 3\Data\Installed Packages\sublime-tern.sublime-package\tern.py", line 528, in plugin_loaded init() File "D:\Program Files\Sublime Text 3\Data\Installed Packages\sublime-tern.sublime-package\tern.py", line 82, in init sync_all_projects() File "D:\Program Files\Sublime Text 3\Data\Installed Packages\sublime-tern.sublime-package\tern.py", line 368, in sync_all_projects sync_project(p) File "D:\Program Files\Sublime Text 3\Data\Installed Packages\sublime-tern.sublime-package\tern.py", line 348, in sync_project ctx.js().locals.startServer(json.dumps(p, ensure_ascii=False), resolved_libs) IndexError: RangeError: Maximum call stack size exceeded ( js/infer.js @ 0 : -1 ) -> // Main type inference engine

sergeche commented 11 years ago

https://github.com/marijnh/tern/issues/16

jodaka commented 11 years ago

got similar error on mac. Installed TernJS using package manager.

Staring TernJS server for /Users/jodaka/git/widgets/gallery.sublime-project with 1 libs and 2091 files
Traceback (most recent call last):
  File "./tern.py", line 82, in init
    sync_all_projects()
  File "./tern.py", line 368, in sync_all_projects
    sync_project(p)
  File "./tern.py", line 348, in sync_project
    ctx.js().locals.startServer(json.dumps(p, ensure_ascii=False), resolved_libs)
IndexError: RangeError: Maximum call stack size exceeded ( js/infer.js @ 302 : 38 )  ->       var match = /^(.*)\.prototype$/.exec(this.proto.name);

After some digging I've discovered that TernJS ignores following configuration from my project file:

"ternjs": {
        "exclude": [ "node_modules/**" ],
        "libs": [ "browser" ]
    }

I've tried removing node_modules catalog and TernJS error disappears and it started working. But when I restored node_modules initial error occurs again.

sergeche commented 11 years ago

Sorry, closed by wrong commit identifier :)

Anyway, your should post such errors to main TernJS repo

jodaka commented 11 years ago

Are you sure it's a TernJS bug, not a sublime-tern? As it seems the problem can be fixed by correct handling of "exclude" property in sublime project config.

sergeche commented 11 years ago

Yes, it’s TernJS bug:

RangeError: Maximum call stack size exceeded ( js/infer.js @ 302 : 38 )

The problem is that TernJS can’t properly parse and infer data in some circumstances. The exclude property simply excludes these files from Tern server so they are not parsed at all.

jodaka commented 11 years ago

Сергей, можно я по-русски отвечу, а то, кажется, моего английского недостаточно, чтобы описать проблему.

Ошибка с парсингом внутри TernJS, это, конечно, плохо. Но я имел в виду, что опция exclude НЕ работает. Т.е. я указываю в ней

"exclude": [ "node_modules/**" ],

и ожидаю, что ни один js файл из node_modules в TernJS отправлен не будет. Однако, эта опция у меня НЕ работает и все JS из node_modules отправляются в TernJS.

sergeche commented 11 years ago

Странно... Я так понимаю, вы на OSX? Можете полностью показать содержимое .sublime-project?

jodaka commented 11 years ago

да, я на OSX сижу. Вот конфиг проекта https://gist.github.com/jodaka/5312826#file-quiz-sublime-project Если я его редактирую и жму Save, то в консоли саблайма видно следующее:

Writing file /Users/jodaka/git/widgets/quiz.sublime-project with encoding UTF-8
Syncing project /Users/jodaka/git/widgets/gallery.sublime-project
Staring TernJS server for /Users/jodaka/git/widgets/gallery.sublime-project with 1 libs and 1014 files

В самом проекте не больше десятка .js файлов, а ещё тысяча штук подсасывается из node_modules

sergeche commented 11 years ago

А можете показать несколько полных путей к JS-файлам из node_modules? Чтобы я проверил, как матчатся пути.

jodaka commented 11 years ago

вот, например, путь к js из пакета grunt-contrib-watch:

/Users/jodaka/git/widgets/quiz/node_modules/grunt-contrib-watch/watch.js

или вот handlebars и его зависимости

/Users/jodaka/git/widgets/quiz/node_modules/handlebars/lib/handlebars.js
/Users/jodaka/git/widgets/quiz/node_modules/handlebars/node_modules/uglify-js/uglify-js.js
/Users/jodaka/git/widgets/quiz/node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/index.js
sergeche commented 11 years ago

Хм, странно: я воссоздал проект по этим данным, и у меня загрузились только нужные файлы. Буду думать ещё.

webuniverseio commented 11 years ago

На винде вроде exclude работает (т.е. дополнений из исключенных файлов нет), но количество найденных файлов тоже не меняется. Может просто число неправильное показывается?

sergeche commented 11 years ago

Не, там правильно всё показывается. Я потом сделаю вывод отладочной информации, чтобы можно было посмотреть, какие именно файлы загружаются.