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

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

Open
monaka opened this issue Sep 12, 2020 · 0 comments
Open

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

monaka opened this issue Sep 12, 2020 · 0 comments

Comments

@monaka
Copy link

monaka commented Sep 12, 2020

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';
      }
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant