Skip to content
This repository was archived by the owner on Jun 29, 2022. It is now read-only.
This repository was archived by the owner on Jun 29, 2022. It is now read-only.

Invalid state by "Connection got disposed" in vscode-jsonrpc. #24

Description

@monaka

I'm using vscode-ws-jsonrpc with Che-Theia.
It gets sporadically connection failures by "Connection got disposed" error from vscode-jsonrpc.

The stack trace is like this.

2020-09-12 07:11:55.100 root ERROR Error: Connection got disposed.
     at Object.dispose (/home/theia/node_modules/vscode-jsonrpc/lib/main.js:904:25)
     at /home/theia/node_modules/vscode-ws-jsonrpc/lib/socket/connection.js:14:41
     at CallbackList.invoke (/home/theia/node_modules/vscode-jsonrpc/lib/events.js:62:39)
     at Emitter.fire (/home/theia/node_modules/vscode-jsonrpc/lib/events.js:121:36)
     at closeHandler (/home/theia/node_modules/vscode-jsonrpc/lib/main.js:240:26)
     at CallbackList.invoke (/home/theia/node_modules/vscode-jsonrpc/lib/events.js:62:39)
     at Emitter.fire (/home/theia/node_modules/vscode-jsonrpc/lib/events.js:121:36)
     at WebSocketMessageReader.fireClose (/home/theia/node_modules/vscode-jsonrpc/lib/messageReader.js:111:27)
     at WebSocketMessageReader.fireClose (/home/theia/node_modules/vscode-ws-jsonrpc/lib/socket/reader.js:67:19)
     at /home/theia/node_modules/vscode-ws-jsonrpc/lib/socket/reader.js:24:18

I googled and I found a lot of "Connection displosed" issue in VSCode comminity.
So I suspect this is caused by bugs in vscode-ws-jsonrpc.

In the other hands, I suppose this can be avoid by writing a workaround code.
My suggestion is like this. Is it acceptable?

      protected fireClose(): void {
          if (this.state === 'initial') {
              this.events.splice(0, 0, {});
          } else if (this.state === 'listening') {
-              super.fireClose();
+              try {
+                super.fireClose();
+              } catch (e) { console.error(e); /* Ignore as the connection may be disposed. */ }
          }
          this.state = 'closed';
      }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions