Skip to content

JS Code with static block exposes 3 issues: Crashes TypeScript language service, ErrorReporter typescript version bug, & lingering bash.exe processes leading to "console allocation failure" #46468

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

Closed
DerekZiemba opened this issue Oct 21, 2021 · 5 comments · Fixed by #46472
Assignees
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Domain: JavaScript The issue relates to JavaScript specifically Fix Available A PR has been opened for this issue Fixed A PR has been merged for this issue

Comments

@DerekZiemba
Copy link

DerekZiemba commented Oct 21, 2021

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.61.2 (system setup) & maybe? 1.61.0 (system setup)
  • OS Version: Win10 Education 20H2 (OS Build 19042.1237)

This was occurring on an earlier version which prompted me to finally click Help -> Install Update. The new version exhibits the same issue. I did not make a note of the version I was coming from, but I can't recall doing an update in the last 7 days so it might be earlier than 1.61.1.

Steps to Reproduce:

  1. Create a javascript file anywhere, or not, this will crash the TypeScript language service even in an unsaved new tab.

  2. Paste the following code: [BUG # 1]:

    class ElementsArray extends Array {
      static {
        const superisArray = super.isArray;
        const customIsArray = (arg)=> superisArray(arg);
        this.isArray = customIsArray;
      }
    }
    • The TypeScript language service should now crash.
    • You may have to Reload Window or close vscode and relaunch it. This may only occur if a tab is open with the above code on vscode statup or Typescript Language Service startup. I can't check now because of bash.exe side-effect ([BUG # 3] further down) caused by this bug.
  3. With the TypeScript language service now crashed > 5 times. The ErrorReporter will prompt you to report the error.

    • [BUG # 2]: The ErrorReporter is unable to report issue because it says the TypeScript version is out of date, even if it is actually the latest version.
      image
  4. [BUG # 3]: The TypeScript Server crashing is resulting in lingering bash shells and apparently there is a limit of 32.
    image

    • EDIT: This actually brings about yet another bug:
      [BUG # 4]: VSCode refuses to display the PROBLEMS OUTPUT DEBUG CONSOLE TERMINAL panel if the terminal can't be started.

EDIT2:
I failed to mention the issue with the TypeScript language service crashing has existed for well over a month, maybe months even. Until this point I would just ignore it and avoid the file that causes the crash. I never tried to report the issue in the past because I was in fact using an older TypeScript version.

Today I finally became annoyed enough to look into it after running into and being impeded for the n-th time by the fatal error - console device allocation failure - which breaks unrelated things system wide.
I slowly removed code from that file until I was left with only the code that would cause the crash, then simplified it further to the 7 line snippet above.
After finding the root cause, I updated my typescript version to latest so that I could submit the issue. Then the rabbit hole got deeper.


EDIT3:

I originally submitted this to the vscode repo instead of the TypeScript repo because my primary beef is with vscode leaving bash.exe consoles open. I also thought the ErrorReporter being broken was a vscode thing.
Yes, the root cause is the TypeScript language server, but I feel vscode's handling of a failed language server is poor.

@DerekZiemba DerekZiemba changed the title 7 lines of JS Code with static block exposes 3 unique bugs: Crashes TypeScript language service, ErrorReporter typescript version bug, & lingering bash.exe processes causing "console device allocation failure" JS Code with static block exposes 3 issues: Crashes TypeScript language service, ErrorReporter typescript version bug, & lingering bash.exe processes leading to "console allocation failure" Oct 21, 2021
@mjbvz mjbvz self-assigned this Oct 21, 2021
@mjbvz mjbvz transferred this issue from microsoft/vscode Oct 21, 2021
@mjbvz mjbvz removed their assignment Oct 21, 2021
@mjbvz
Copy link
Contributor

mjbvz commented Oct 21, 2021

Confirmed with 4.5.0-dev.20211021. Here's the error stack:

  ERR <syntax> TypeScript Server Error (4.5.0-dev.20211021)
Debug Failure. Unexpected node.
Node ClassStaticBlockDeclaration was unexpected.
Error: Debug Failure. Unexpected node.
Node ClassStaticBlockDeclaration was unexpected.
    at bindThisPropertyAssignment (/Users/matb/projects/san/node_modules/typescript/lib/tsserver.js:45720:30)
    at bindWorker (/Users/matb/projects/san/node_modules/typescript/lib/tsserver.js:45337:29)
    at bind (/Users/matb/projects/san/node_modules/typescript/lib/tsserver.js:45208:13)
    at bindExpressionStatement (/Users/matb/projects/san/node_modules/typescript/lib/tsserver.js:44254:13)
    at bindChildren (/Users/matb/projects/san/node_modules/typescript/lib/tsserver.js:43721:21)
    at bind (/Users/matb/projects/san/node_modules/typescript/lib/tsserver.js:45219:21)
    at /Users/matb/projects/san/node_modules/typescript/lib/tsserver.js:43657:94
    at Object.forEach (/Users/matb/projects/san/node_modules/typescript/lib/tsserver.js:197:30)
    at bindEach (/Users/matb/projects/san/node_modules/typescript/lib/tsserver.js:43664:16)
    at bindEachFunctionsFirst (/Users/matb/projects/san/node_modules/typescript/lib/tsserver.js:43657:13)
    at bindChildren (/Users/matb/projects/san/node_modules/typescript/lib/tsserver.js:43774:21)
    at bind (/Users/matb/projects/san/node_modules/typescript/lib/tsserver.js:45219:21)
    at visitNode (/Users/matb/projects/san/node_modules/typescript/lib/tsserver.js:29626:24)
    at Object.forEachChild (/Users/matb/projects/san/node_modules/typescript/lib/tsserver.js:29760:21)
    at bindEachChild (/Users/matb/projects/san/node_modules/typescript/lib/tsserver.js:43667:16)
    at bindChildren (/Users/matb/projects/san/node_modules/typescript/lib/tsserver.js:43788:21)
    at bindContainer (/Users/matb/projects/san/node_modules/typescript/lib/tsserver.js:43613:17)
    at bind (/Users/matb/projects/san/node_modules/typescript/lib/tsserver.js:45222:21)
    at Object.forEach (/Users/matb/projects/san/node_modules/typescript/lib/tsserver.js:197:30)
...

@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Domain: JavaScript The issue relates to JavaScript specifically Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output labels Oct 21, 2021
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 4.5.1 milestone Oct 21, 2021
@DanielRosenwasser
Copy link
Member

Simpler repro

class Thing {
  static {
    this.doSomething = () => {};
  }
}

@DanielRosenwasser
Copy link
Member

Fix is up at #46472, thanks for finding a small repro for us!

I'm not sure if the last 2 problems you reported are really just residual issues caused by the LS crash. @mjbvz might know better.

@DanielRosenwasser DanielRosenwasser added the Fixed A PR has been merged for this issue label Oct 22, 2021
@DanielRosenwasser
Copy link
Member

If you switch to the TypeScript nightly extension, you should get the fix some time this weekend.

@DerekZiemba
Copy link
Author

DerekZiemba commented Oct 23, 2021

@DanielRosenwasser Thanks for addressing this so quickly!

I was actually impatient so I cloned the repo, pulled this branch, built it, then hackily pasted the lib folder over C:\Users\Derek\AppData\Local\Volta\tools\image\packages\typescript\node_modules\typescript\lib.

Everything's been working fine.

I'm actually kind of in disbelief how smoothly everything went. Nine out of ten times I clone a repo with the intention to build it, either the documentation on how to build it is lacking or the build fails. Quality repo you guys have here 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Domain: JavaScript The issue relates to JavaScript specifically Fix Available A PR has been opened for this issue Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants