Skip to content

Decorator declaration inside a function causes the typescript language server to crashΒ #62657

@devilofhell

Description

@devilofhell

πŸ”Ž Search Terms

decorator language server crash

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried (5.9.3 and 5.4.5), and I reviewed the FAQ for entries about "decorator"

⏯ Playground Link

https://www.typescriptlang.org/play/?#code/KYDwDg9gTgLgBAMwK4DsDGMCWEVwM4zBgAUMAhlAObAwBccxAdMxZXvWSgJ4DaAugEo4AXgB8cTlwA0cNDkIg6cAMIAbMnjwBZGgAsIAEwAiwOVDIxoy+aBhCA3gCg4LuFBpIouZOiw43ROpowAC2wCgwOjD6BkwsVOwS3A7OrmlyKARwKGRhInDRmHiMGQRQSBjQjDl5ANRwAESMDXD1xBkKMNW5wBJ4+DBQmCiUQvUNxC1trP0aA0MjY40CDQDcqWku7jCeuIQEjARExDXAMhpc6AxCYnBOmw8BO14SAO5kmPDkVDQlZKqqUi6IoyZiMGYCdaPOAAX0hG1h6xhjkcaHUmjgAGUIGE1Bp+vdXKVBhVLFBiGAkAAjVSYNABMgGHCqLhwMD0AAKZGoDmRCIAAkcwAiLldKBBLNiwlzqMRPKp6GVhqM7gi0oLCMLoWR3p8CsDimBGOLLHKoKp4WlkciXEA

πŸ’» Code

import { Page, test } from "@playwright/test";

export function step(target: (...args: any[]) => any, context: ClassMethodDecoratorContext) {
    return function replacementMethod(...args: any) {
        const name = this.constructor.name + "." + (context.name as string) + "(" + (args as string) + ")";
        return test.step(name, async () => {
            return await target.call(this, ...args);
        });
    };
}

class SomeClass {
    constructor(public readonly p: Page) {}

    @step
    async gotoSomePage(url: string) {
        @step
        await this.p.goto(url);
    }
}

πŸ™ Actual behavior

when (by accident) a decorator method was added into a function (line 17 / line 15 in the TS Playground), the typescript language server just gives up and exits with SIGTERM.

πŸ™‚ Expected behavior

mark the second decorator as wrong, or at least have the language-server exit SIGTERM with a more meaningful explanation into the Logfiles. Have it print out, in which location the language server failed. tsc just print "Error: Debug Failure. False expression."

In my Repo, I had 10 files changed and I was looking for 4 hours to find the issue.

Additional information about the issue

I uploaded this to a repository here: https://github.com/devilofhell/decorator-crashes-ts-language-service/blob/main/page.ts


Here is a picture of the VS Code log:
Image

Note: this only happens after you start VS Code, or open a new file, since only that triggers the language server to build up its content. VS Code just gives up after 5 retries.


here is the log file from /home/r975115/.vscode-server/data/logs/20251022T110530/exthost7/vscode.typescript-language-features/tsserver-log-cYXMY8/tsserver.log

tsserver.log


if executing tsc, it says nothing meaningful. no information why or where it crashed.

/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:1284
    throw e;
    ^

Error: Debug Failure. False expression.
    at parseVariableDeclarationList (/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:33762:15)
    at parseVariableStatement (/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:33788:29)
    at parseDeclarationWorker (/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:33602:16)
    at parseDeclaration (/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:33584:14)
    at parseStatement (/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:33537:16)
    at parseListElement (/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:30115:12)
    at parseList (/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:30100:19)
    at parseBlock (/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:32993:26)
    at parseFunctionBlock (/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:33024:19)
    at parseFunctionBlockOrSemicolon (/home/r975115/Repositories/decorator-crashes-ts-language-service/node_modules/typescript/lib/_tsc.js:33667:12)

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions