Skip to content
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

remove unexpected tsserver messages in server logs #338

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/warm-bugs-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@srcbook/api': patch
---

remove unexpected tsserver messages in server logs
13 changes: 9 additions & 4 deletions packages/api/tsserver/tsserver.mts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ export class TsServer extends EventEmitter {
this.process.stdin?.write(JSON.stringify(request) + '\n');
}

private sendWithoutResponse(request: tsserver.protocol.Request) {
this.resolvers[request.seq] = () => {};
this.send(request);
}

private sendWithResponsePromise<T>(request: tsserver.protocol.Request) {
return new Promise<T>((resolve) => {
this.resolvers[request.seq] = resolve;
Expand Down Expand Up @@ -123,7 +128,7 @@ export class TsServer extends EventEmitter {
* This is used to tell tsserver to start tracking a file and all its dependencies.
*/
open(args: tsserver.protocol.OpenRequestArgs) {
return this.send({
return this.sendWithoutResponse({
seq: this.seq,
type: 'request',
command: 'open',
Expand All @@ -137,7 +142,7 @@ export class TsServer extends EventEmitter {
* This is used to tell tsserver to stop tracking a file.
*/
close(args: tsserver.protocol.FileRequestArgs) {
return this.send({
return this.sendWithoutResponse({
seq: this.seq,
type: 'request',
command: 'close',
Expand All @@ -153,7 +158,7 @@ export class TsServer extends EventEmitter {
* Note that the diagnostics are sent as asynchronous events instead of responding to this request.
*/
geterr(args: tsserver.protocol.GeterrRequestArgs) {
this.send({
this.sendWithoutResponse({
seq: this.seq,
type: 'request',
command: 'geterr',
Expand All @@ -169,7 +174,7 @@ export class TsServer extends EventEmitter {
* errors that can occur when renaming files.
*/
reloadProjects() {
this.send({
this.sendWithoutResponse({
seq: this.seq,
type: 'request',
command: 'reloadProjects',
Expand Down