sst / ion

SST v3
https://sst.dev
MIT License
1.39k stars 180 forks source link

Adding breakpoints in Live #73

Open jayair opened 5 months ago

jayair commented 5 months ago

Currently the launch config points to node_modules, need to try it with the new CLI.

https://discord.com/channels/983865673656705025/1177071497974648952/1221590450314416180

ION-219

Itsthatotherguy commented 3 months ago

Any update on how we can get debug working with Ion? As mentioned, the launch config points to node_modules but there is no sst in the .bin directory of my node_modules.

Also, this starts the debugger but doesn't trigger any breakpoints:

{
      "name": "SST",
      "type": "node-terminal",
      "request": "launch",
      "command": "sst dev",
      "cwd": "${workspaceFolder}",
      "skipFiles": ["<node_internals>/**"]
}

Edit: The launch config referred to in the docs also doesn't work: https://ion.sst.dev/docs/live/#breakpoints

dmeehan1968 commented 3 months ago

I'm not sure if this is the same issue, but I want to be able to debug the client side. I'm using Jetbrains (PHPStorm but would be the same for any of their IDE's). If I try running sst dev next dev I get the following output:

 sst dev next dev

SST ❍ ion 0.0.368  ready!

➜  App:        <REDACTED>
   Stage:      <REDACTED>
   Console:    <REDACTED>

~  Deploying

|  Error       default_6_35_0 pulumi:providers:aws pulumi:providers:aws resource 'default_6_35_0' has a problem: unable to validate AWS credentials.
Details: validating provider credentials: retrieving caller identity from STS: operation error STS: GetCallerIdentity, https response error StatusCode: 0, RequestID: , request send failed, Post "https://sts.eu-west-1.amazonaws.com/": dial tcp: lookup sts.eu-west-1.amazonaws.com: no such host

×  Failed
   default_6_35_0 pulumi:providers:aws
   pulumi:providers:aws resource 'default_6_35_0' has a problem: unable to validate AWS credentials.
Details: validating provider credentials: retrieving caller identity from STS: operation error STS: GetCallerIdentity, https response error StatusCode: 0, RequestID: , request send failed, Post "https://sts.eu-west-1.amazonaws.com/": dial tcp: lookup sts.eu-west-1.amazonaws.com: no such host

I suspect the docs just need some improvement around how to debug either the frontend or backend.

jayair commented 3 months ago

@dmeehan1968 how's this related to setting breakpoints?

dmeehan1968 commented 3 months ago

@dmeehan1968 how's this related to setting breakpoints?

I said I wasn't sure if this was related, but I can't debug at all. The docs don't cover debug adequately for me to distinguish.

nirweiner2 commented 3 months ago

I really wish we could make it work.

nirweiner2 commented 3 months ago

It seems like it works to manually search for the node lambda process and attach it through vscode

nirweiner2 commented 3 months ago

VS Code's ability to attach to child Node.js processes can be influenced by the presence of non-Node.js intermediary processes. In this case, the pnpm run dev would essentially run sh -c sst dev which would then trigger the execution of the lambda node. And, that would break the chain. I believe it has something to do with it.

nirweiner2 commented 3 months ago

It is possible that adding --inspect to https://github.com/sst/ion/blob/3b273dd735cfa4659fae5714468d5832dfda0156/pkg/runtime/node.go#L203 would solve it. Does anyone want to try?

lagnat commented 3 months ago

Possibly relevant: https://github.com/microsoft/vscode/issues/40123#issuecomment-361529571

jayair commented 3 months ago

That's helpful I think. @thdxr is there something we need to set on our side for this?

lagnat commented 3 months ago

Spent a little time playing around with some ideas here but so far it's not looking good. My guess is that the sst server process is the air-gap that is stopping VSCode from detecting the child node processes.

lagnat commented 3 months ago

The lack of debugger support is quickly becoming a show stopper. Separate node processes for each invocation also seems that it could complicate matters. Hope you guys have something planned here.

jayair commented 3 months ago

Yeah it's on the roadmap. We'll get to this in the coming weeks.

syhner commented 2 months ago

Workaround in the meantime:

  1. Install https://marketplace.visualstudio.com/items?itemName=augustocdias.tasks-shell-input

  2. Edit .vscode/launch.json

    {
    "version": "0.2.0",
    "configurations": [
    {
      "name": "Debug SST Live",
      "type": "node",
      "request": "attach",
      "processId": "${input:sst_pid}"
    }
    ],
    "inputs": [
    {
      "id": "sst_pid",
      "type": "command",
      "command": "shellCommand.execute",
      "args": {
        "command": "ps | grep '.sst/platform/dist/nodejs-runtime/index.js' | grep -v grep | awk '{print $1}'",
        "useFirstResult": true
      }
    }
    ]
    }
  3. Run sst dev

  4. Invoke what you're trying to debug (e.g. Lambda function) if it needs to get warm

  5. Run the Debug SST Live configuration

  6. Set breakpoints

Lambda invocation should now trigger the breakpoint

jorenvh1 commented 1 month ago

@jayair Any update on this?

jayair commented 1 month ago

Yeah apparently @thdxr almost has it working.

Aswin-osyte commented 1 month ago
 {
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug SST Live",
      "type": "node",
      "request": "launch",
      "runtimeArgs": ["dev"],
      "console": "integratedTerminal",
      "skipFiles": ["<node_internals>/**"],
      "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst"
    }
  ]
}

@jayair @thdxr the config mentioned on the sst.ion docs doestn't seems like working. Is there any update on this issue?