Skip to content

Commit 86c10ed

Browse files
author
Keen Yee Liau
committed
fix: TSC_NONPOLLING_WATCHER should be set when process is spawned
Setting the environment variable in the code after the process is launched is too late. It has no effect. Instead, the parameter should be specified as part of the server process spawn options.
1 parent 7e6bb37 commit 86c10ed

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

client/src/extension.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,27 @@ import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, Re
55

66
export function activate(context: ExtensionContext) {
77
// The server is implemented in node
8-
let serverModule = context.asAbsolutePath(path.join('server', 'server.js'));
9-
// The debug options for the server
10-
let debugOptions = { execArgv: ["--nolazy", "--debug=6009"] };
8+
const serverModule = context.asAbsolutePath(path.join('server', 'server.js'));
9+
const options = {
10+
module: serverModule,
11+
transport: TransportKind.ipc,
12+
options: {
13+
env: {
14+
// Force TypeScript to use the non-polling version of the file watchers.
15+
TSC_NONPOLLING_WATCHER: true,
16+
},
17+
},
18+
};
1119

1220
// If the extension is launched in debug mode then the debug server options are used
1321
// Otherwise the run options are used
14-
let serverOptions: ServerOptions = {
15-
run : { module: serverModule, transport: TransportKind.ipc },
16-
debug: { module: serverModule, transport: TransportKind.ipc /* *, options: debugOptions /* */ }
22+
const serverOptions: ServerOptions = {
23+
run : options,
24+
debug: options,
1725
}
1826

1927
// Options to control the language client
20-
let clientOptions: LanguageClientOptions = {
28+
const clientOptions: LanguageClientOptions = {
2129
// Register the server for Angular templates
2230
documentSelector: ['ng-template', 'html', 'typescript'],
2331

@@ -34,7 +42,7 @@ export function activate(context: ExtensionContext) {
3442
}
3543

3644
// Create the language client and start the client.
37-
let disposable = new LanguageClient('Angular Language Service', serverOptions, clientOptions, true).start();
45+
const disposable = new LanguageClient('Angular Language Service', serverOptions, clientOptions, true).start();
3846

3947
// Push the disposable to the context's subscriptions so that the
4048
// client can be deactivated on extension deactivation

server/src/server.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
* Licensed under the MIT License. See License.txt in the project root for license information.
55
* ------------------------------------------------------------------------------------------ */
66

7-
8-
9-
// Force TypeScript to use the non-polling version of the file watchers.
10-
process.env["TSC_NONPOLLING_WATCHER"] = String(true);
11-
127
import * as ng from '@angular/language-service';
138

149
import {

0 commit comments

Comments
 (0)