-
Notifications
You must be signed in to change notification settings - Fork 123
Referencing "ts" file as a templateUrl in component file crashes the service #2166
Description
🐞 bug report
Is this a regression?
I don't know. Most likely no.
Description
If you erroneously reference a .ts file in @Component({templateUrl}) the angular language service crashes and permanently stops working giving the "The Angular Language Service server crashed 5 times in the last 3 minutes. The server will not be restarted." message.
Bug Type
What does this bug affect
- Angular Language Service VSCode extension
- Angular Language Service server
Reproduction
Steps to reproduce the behavior:
- Create a new angular project using "ng new"
- Open vscode and install angular language service
- Open app.component.ts and change the value "templateUrl" in
@Componentdecorator to "'app.component.ts" - Angular language service should crash
app.component.ts code that causes the service to crash below:
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
@Component({
selector: 'app-root',
standalone: true,
imports: [RouterOutlet],
templateUrl: 'app.component.ts',
styleUrl: './app.component.css'
})
export class AppComponent {
title = 'repro';
}
Expected behavior
This should fail gracefully, by either underlining the problem to the user or ignoring wrong references to the 'ts' file
Logs
Log file gives us deep insight into the behavior and performance of the extension. If the issue is a performance
problem or an error occured, please provide the output of the log file below.
Set Angular Log level to verbose.
Err 29 [8:36:53.508] Error: readResource() should not be called on TS file: **HOME DIRECTORY**repro/repro/src/app/app.component.ts
at LanguageServiceAdapter.readResource (**HOME DIRECTORY**.vscode/extensions/angular.ng-template-19.2.2/node_modules/@angular/language-service/bundles/language-service.js:72342:23)
at AdapterResourceLoader.load (**HOME DIRECTORY**.vscode/extensions/angular.ng-template-19.2.2/node_modules/@angular/language-service/bundles/language-service.js:65071:32)
at extractTemplate (**HOME DIRECTORY**.vscode/extensions/angular.ng-template-19.2.2/node_modules/@angular/language-service/bundles/language-service.js:49486:52)
at ComponentDecoratorHandler.analyze (**HOME DIRECTORY**.vscode/extensions/angular.ng-template-19.2.2/node_modules/@angular/language-service/bundles/language-service.js:59811:28)
at TraitCompiler.analyzeTrait (**HOME DIRECTORY**.vscode/extensions/angular.ng-template-19.2.2/node_modules/@angular/language-service/bundles/language-service.js:42095:40)
at analyze (**HOME DIRECTORY**.vscode/extensions/angular.ng-template-19.2.2/node_modules/@angular/language-service/bundles/language-service.js:42061:44)
at TraitCompiler.analyzeClass (**HOME DIRECTORY**.vscode/extensions/angular.ng-template-19.2.2/node_modules/@angular/language-service/bundles/language-service.js:42083:21)
at visit (**HOME DIRECTORY**.vscode/extensions/angular.ng-template-19.2.2/node_modules/@angular/language-service/bundles/language-service.js:41860:26)
at visitNodes (**HOME DIRECTORY**.vscode/extensions/angular.ng-template-19.2.2/node_modules/typescript/lib/typescript.js:32316:22)
at forEachChildInSourceFile (**HOME DIRECTORY**.vscode/extensions/angular.ng-template-19.2.2/node_modules/typescript/lib/typescript.js:32529:12)
Screenshots
If applicable, add screenshots to help explain your problem.
n/a
🌍 Your Environment
Angular Version:
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 18.2.16
Node: 20.17.0
Package Manager: npm 10.8.2
OS: linux x64
Angular: 18.2.13
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1802.16
@angular-devkit/build-angular 18.2.16
@angular-devkit/core 18.2.16
@angular-devkit/schematics 18.2.16
@angular/cli 18.2.16
@schematics/angular 18.2.16
rxjs 7.8.2
typescript 5.5.4
zone.js 0.14.10
Extension Version:
v. 19.2.2
VSCode Version:
1.98.2
Operating System:
OS: Linux Mint 22 Cinnamon
Cinnamon Version: 6.2.9
Linux Kernel: 6.8.0-55-generic
Extension options:
{
"angular.log": "terse"
}
Anything else relevant?