xstate-tools icon indicating copy to clipboard operation
xstate-tools copied to clipboard

VSCode extension (1.7.2) does not show prompt for editor / inspector

Open mdpratt opened this issue 2 years ago • 21 comments

The ability to open the visual editor or inspector is no longer working. I've validated that the issue is present all 1.7.x installs. I've downgraded to 1.6.0 for the time being, which is still working.

Version 1.6.0 image

Version 1.7.2 image

mdpratt avatar Mar 06 '22 09:03 mdpratt

@mdpratt Can't repeat this on my machine, could you do two things:

  1. Give me info about your OS/node version
  2. Check the 'output' for XState in VSCode here. You might be able to spot some errors.

image

mattpocock avatar Mar 07 '22 09:03 mattpocock

I'm using Remote-SSH to connect to an AWS EC2 instance that I develop from. As such, I'm not seeing an XState output in my list. Looking through other logs, I'm seeing a few things:

Log (Remote Exentsion)

[2022-03-07 11:26:52.546] [exthost] [info] ExtensionService#_doActivateExtension statelyai.stately-vscode, startup: false, activationEvent: 'onLanguage:typescript'

Remote host: OS:

NAME="Amazon Linux"
VERSION="2"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2:-:"
HOME_URL="https://amazonlinux.com/"
  • Node: v17.6.0
  • NPM: 8.5.1

Local host:

  • Windows 10 (Version 20H2, Build 19042.1526)
  • Node: v17.6.0
  • NPM: 8.5.1

mdpratt avatar Mar 07 '22 11:03 mdpratt

Downgrading to v1.7.0 does produce this error though:

[2022-03-07 11:37:22.681] [exthost] [error] Activating extension statelyai.stately-vscode failed due to an error:
[2022-03-07 11:37:22.681] [exthost] [error] Error: Connection to server got closed. Server will not be restarted.
	at LanguageClient2.handleConnectionClosed (/local/home/mdpratt/.vscode-server/extensions/statelyai.stately-vscode-1.7.0/dist/index.js:11926:43)
	at LanguageClient2.handleConnectionClosed (/local/home/mdpratt/.vscode-server/extensions/statelyai.stately-vscode-1.7.0/dist/index.js:14324:15)
	at closeHandler (/local/home/mdpratt/.vscode-server/extensions/statelyai.stately-vscode-1.7.0/dist/index.js:11900:16)
	at CallbackList.invoke (/local/home/mdpratt/.vscode-server/extensions/statelyai.stately-vscode-1.7.0/dist/index.js:3035:35)
	at Emitter.fire (/local/home/mdpratt/.vscode-server/extensions/statelyai.stately-vscode-1.7.0/dist/index.js:3086:34)
	at closeHandler (/local/home/mdpratt/.vscode-server/extensions/statelyai.stately-vscode-1.7.0/dist/index.js:4181:24)
	at CallbackList.invoke (/local/home/mdpratt/.vscode-server/extensions/statelyai.stately-vscode-1.7.0/dist/index.js:3035:35)
	at Emitter.fire (/local/home/mdpratt/.vscode-server/extensions/statelyai.stately-vscode-1.7.0/dist/index.js:3086:34)
	at IPCMessageReader.fireClose (/local/home/mdpratt/.vscode-server/extensions/statelyai.stately-vscode-1.7.0/dist/index.js:3228:27)
	at ChildProcess.<anonymous> (/local/home/mdpratt/.vscode-server/extensions/statelyai.stately-vscode-1.7.0/dist/index.js:5168:45)
	at ChildProcess.emit (events.js:327:22)
	at maybeClose (internal/child_process.js:1048:16)
	at Socket.<anonymous> (internal/child_process.js:439:11)
	at Socket.emit (events.js:315:20)
	at Pipe.<anonymous> (net.js:673:12)

mdpratt avatar Mar 07 '22 11:03 mdpratt

I've tried downgrading my Node to v16.14.0, and I've also tried using the extension only against a local project as well now, to no avail.

mdpratt avatar Mar 07 '22 12:03 mdpratt

I'm also experiencing similar issues with Versions 1.7.1 and 1.7.2. Using version 1.6.0 still shows the action buttons for opening visual editor and inspector same as in the issue description.

I'm currently running:

ProductName:    macOS
ProductVersion: 11.6
BuildVersion:   20G165

Node: v14.16.1

I also experimented downgrading to version 1.7.0 and that version will print out the following stacktrace to vscode output-console. This might be unrelated to the issue with the newer versions

internal/modules/cjs/loader.js:937
  throw err;

Error: Cannot find module 'prettier'
Require stack:
- /Users/currentUser/.vscode/extensions/statelyai.stately-vscode-1.7.0/dist/server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:934:15)
    at Module._load (internal/modules/cjs/loader.js:779:27)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
    at Module.require (internal/modules/cjs/loader.js:1006:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at ../../../packages/shared/dist/xstate-tools-shared.cjs.dev.js (/Users/currentUser/.vscode/extensions/statelyai.stately-vscode-1.7.0/dist/server.js:88235:20)
    at __require (/Users/currentUser/.vscode/extensions/statelyai.stately-vscode-1.7.0/dist/server.js:10:50)
    at ../../../packages/shared/dist/xstate-tools-shared.cjs.js (/Users/currentUser/.vscode/extensions/statelyai.stately-vscode-1.7.0/dist/server.js:89006:25)
    at __require (/Users/currentUser/.vscode/extensions/statelyai.stately-vscode-1.7.0/dist/server.js:10:50)
    at Object.<anonymous> (/Users/currentUser/.vscode/extensions/statelyai.stately-vscode-1.7.0/dist/server.js:89015:36) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/currentUser/.vscode/extensions/statelyai.stately-vscode-1.7.0/dist/server.js'
  ]
}
[Info  - 12:17:37 PM] Connection to server got closed. Server will restart.

VillePakarinenPosti avatar Mar 09 '22 10:03 VillePakarinenPosti

@VillePakarinenPosti The prettier issue is fixed by 1.7.1.

mattpocock avatar Mar 09 '22 13:03 mattpocock

@VillePakarinenPosti @mdpratt Could you try downloading the VSIX from this GH action artifact?

https://github.com/statelyai/xstate-tools/actions/runs/1957631757

LMK if you need any help installing an extension from .vsix - it's available from the command palette in VSCode.

mattpocock avatar Mar 09 '22 13:03 mattpocock

@mattpocock Using the provided .vsix file fixed the issue for me.

VillePakarinenPosti avatar Mar 09 '22 14:03 VillePakarinenPosti

Beautiful, thanks!

mattpocock avatar Mar 09 '22 17:03 mattpocock

Unfortunately installing from the .vsix did not solve this issue for me. The machine causing this problem for me can be found here: https://codesandbox.io/s/jolly-shtern-sp9bnt?file=/src/import.ts

mdpratt avatar Mar 10 '22 09:03 mdpratt

@mdpratt Thanks for the repro! I got pretty far with working out what's wrong.

It looks like we're failing at parsing a couple of things in your machine, and they're causing errors.

First, passing the key as a template literal is weirdly causing an error:

import { createMachine } from "xstate";

const machine = createMachine({
  key: `Nice`,
});

Second, declaring 'after' as an array is also causing an error:

import { createMachine } from "xstate";

const machine = createMachine({
  after: [
    {
      delay: 400,
    },
  ],
});

Both of these errors are swallowed, meaning you don't get any indication in the UI that something is wrong.

@mdpratt Could you confirm that if you create a new file with createMachine({}), the code lens options show up?

mattpocock avatar Mar 10 '22 10:03 mattpocock

This worked for me. I can also confirm that the latest v1.7.3 also appears to work. Sometimes I have to close the tab and open it a few times to get it registering, but core functionality appears to be restored.

mdpratt avatar Mar 10 '22 20:03 mdpratt

Fantastic, closing but @VillePakarinenPosti feel free to reopen if it doesn't work for you any more.

mattpocock avatar Mar 10 '22 21:03 mattpocock

Unfortunately the 1.7.3 didn't resolve the issue for me.

I'm not seeing any new errors with the latest version but it seems like my issue doesn't have anything to do with the parsing-phase since the extension fails even for the empty machine.

Custom 1.7.2 .vsix image

Latest 1.7.3 image

VillePakarinenPosti avatar Mar 11 '22 07:03 VillePakarinenPosti

@VillePakarinenPosti Any output in the output area of the extension?

Is there anything else in those files?

mattpocock avatar Mar 11 '22 08:03 mattpocock

Is there anything else in those files?

No. I just created an empty file to test if the issue was somehow related to the parsing you mentioned in https://github.com/statelyai/xstate-tools/issues/96#issuecomment-1063909271

Any output in the output area of the extension?

Unfortunately not. I would like to help debugging this further if you can provide a build which would be more verbose.

VSCode info:
Version: 1.65.2
Commit: c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1
Date: 2022-03-10T14:33:49.188Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin x64 20.6.0

VillePakarinenPosti avatar Mar 11 '22 09:03 VillePakarinenPosti

@VillePakarinenPosti Could you try putting your machine's code into this site:

https://xstate-parser-example-site.vercel.app/

To see if it parses correctly.

mattpocock avatar Mar 21 '22 11:03 mattpocock

Yeah it does and here is the parsed result for one of the machines:

[
  {
    "id": "LiveAgentMachine",
    "initial": "idle",
    "states": {
      "idle": {
        "always": {
          "target": "loading"
        }
      },
      "loading": {
        "invoke": {
          "src": "16ejqm",
          "id": "loadEmbbeddedService",
          "onDone": {
            "target": "success"
          },
          "onError": {
            "target": "failure",
            "actions": [
              "setError",
              "removeScript"
            ]
          }
        }
      },
      "success": {
        "initial": "boot",
        "exit": "cleanUpConnections",
        "states": {
          "boot": {
            "always": [
              {
                "target": "bootstrapped",
                "cond": "embeddedServiceRendered"
              },
              {
                "target": "idle"
              }
            ]
          },
          "idle": {
            "on": {
              "INITIALIZE_SERVICE": {
                "target": "initializing"
              }
            }
          },
          "initializing": {
            "entry": "setChatOptions",
            "on": {
              "INITIALIZE_SERVICE": {
                "target": "initializing"
              }
            },
            "invoke": {
              "src": "initializeEmbeddedService",
              "id": "intializeEmbeddedService",
              "onDone": {
                "target": "initialized",
                "actions": "setAvailability"
              },
              "onError": {
                "target": "initializeFailed",
                "actions": "setError"
              }
            }
          },
          "initialized": {
            "on": {
              "AVAILABILITY_CHANGE": {
                "target": "initialized",
                "actions": "setAvailability"
              },
              "START_CHAT": {
                "target": "bootstrapping",
                "cond": "agentIsAvailable"
              },
              "INITIALIZE_SERVICE": {
                "target": "initializing"
              }
            }
          },
          "initializeFailed": {
            "on": {
              "INITIALIZE_SERVICE": {
                "target": "initializing"
              }
            }
          },
          "bootstrapping": {
            "after": {
              "60000": {
                "target": "bootstrappingFailed",
                "actions": "setError"
              }
            },
            "invoke": {
              "src": "1ch3grd",
              "id": "startChat",
              "onDone": {
                "target": "bootstrapped",
                "actions": "addAfterDestroyCleanup"
              },
              "onError": {
                "target": "bootstrappingFailed",
                "actions": "setError"
              }
            }
          },
          "bootstrapped": {
            "on": {
              "END_CHAT": {
                "target": "idle"
              }
            }
          },
          "bootstrappingFailed": {
            "on": {
              "INITIALIZE_SERVICE": {
                "target": "initializing"
              }
            }
          }
        }
      },
      "failure": {}
    }
  }
]

I'm also using "@xstate/cli": "^0.1.3", which parses the machine correctly and generates the proper types. So the issue doesn't seem to be machine related.

VillePakarinenPosti avatar Mar 21 '22 11:03 VillePakarinenPosti

@VillePakarinenPosti Apologies for letting this issue go a little cold. Can you confirm that with the latest builds, things aren't showing?

mattpocock avatar Apr 05 '22 09:04 mattpocock

Just installed the latest version v1.7.5 & updated vscode to version 1.66.2. Still facing the issue and no new findings from any of the output sources.

The custom .vsix build https://github.com/statelyai/xstate-tools/actions/runs/1957631757 still works.

VillePakarinenPosti avatar Apr 13 '22 06:04 VillePakarinenPosti

@VillePakarinenPosti would you be willing to schedule a call with me so we could figure out together what's going on there?

Andarist avatar Nov 08 '22 16:11 Andarist