sst / ion

❍ — a new engine for SST
https://ion.sst.dev
MIT License
1.34k stars 173 forks source link

Panic when running `sst dev` #653

Open breningham opened 1 month ago

breningham commented 1 month ago

Hi, i am having issues with SST ion, we are trying to make use of it in an Nx workspace, and encountered an issue where running anything with sst dev [command] would spit out an error that looks like this: (this is the result of deploy, but same error when running sst dev too )

> pnpm exec sst deploy --profile sandbox --stage=development
Usage: sst deploy

Flags:
  --stage       The stage to deploy to
  --verbose     Enable verbose logging
  --help        Print help
  --target      Comma seperated list of target URNs

Examples:
  sst deploy --stage=production

Learn more at https://ion.sst.dev
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x30 pc=0x101f42670]

goroutine 1 [running]:
github.com/sst/ion/cmd/sst/cli.(*Cli).PrintHelp(...)
        /home/runner/work/ion/ion/cmd/sst/cli/cli.go:109
main.run()
        /home/runner/work/ion/ion/cmd/sst/main.go:80 +0x260
main.main()
        /home/runner/work/ion/ion/cmd/sst/main.go:41 +0x12c 

thinking that Nx may somehow be the culprit i created an empty nextjs app, using pnpm create next-app with all defaults and then ran sst init this all claims to be successful, however when running pnpm dev i recieve a similar error to the above:


❯ pnpm dev --profile sandbox

> my-app@0.1.0 dev /Users/breningham/Projects/my-app
> sst dev next dev "--profile" "sandbox"

Usage: sst dev [command]

Flags:
  --stage       The stage to deploy to
  --verbose     Enable verbose logging
  --help        Print help
  --silent      Do not output function invocation logs

Examples:
  sst dev
  sst dev next dev
  sst dev "next dev --turbo"

Learn more at https://ion.sst.dev
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x30 pc=0x103816670]

goroutine 1 [running]:
github.com/sst/ion/cmd/sst/cli.(*Cli).PrintHelp(...)
        /home/runner/work/ion/ion/cmd/sst/cli/cli.go:109
main.run()
        /home/runner/work/ion/ion/cmd/sst/main.go:80 +0x260
main.main()
        /home/runner/work/ion/ion/cmd/sst/main.go:41 +0x12c
breningham commented 1 month ago

FWIW:  

 Node   : 20.12.0
OS     : darwin-arm64
pnpm   : 9.4.0
SST: 0.0.499 (installed with brew)
jayair commented 1 month ago

Hmm that's pretty strange.

kyleamazza commented 1 month ago

I noticed this on Ubuntu 24.04 & OSX (arm) also, Node v20.11.1. I found the last non-panic-ing SST version to be 0.0.485 when installing (i.e. the panic starts from version 0.0.486 and onwards)

For me, I got the error when running sst --version (sic) (The regular command sst version works normally) as well as sst dev.

wenzf commented 1 month ago

For me, I got the error when running sst --version (sic) (The regular command sst version works normally) as well as sst dev.

Same with me. And sst dev remix vite:dev throws an unexpected error

breningham commented 1 month ago

I found out that this error essentially happens whenever the cli does not understand an argument - for me it was the --profile=[profile] that tripped it up. but since it does not understand --version it makes sense that its throwing the same error.

Ideally, this should be fixed with an error message that states what it did not understand; im not a go developer, but i may look into helping with this on my free time.

NB: if you are using SSO/AWS Profiles, the workaround is to use the AWS_PROFILE=[profile] environment variable instead of --profile.

@wenzf have you tried wrapping the command in quotes? like: sst dev "remix vite:dev"

wenzf commented 1 month ago

@breningham

Yes. Same result with "dev": "sst dev \"remix vite:dev\"" or using single quotes.

Worth noting that I'm using SST the very first time and I might miss a very basic thing leading to this error.

breningham commented 1 month ago

yeah this is my first time delving into SST, i have to say with ION being recommended to new users, i would have thought this stuff might have been ironed out a little. (i get that its pre-release, but IT IS RECOMMENDED for new starters...madness 😆 )

for the sake of people being able to help; @wenzf are you able to share the error you are receiving?

breningham commented 1 month ago

also, try adding --verbose to your command, it should tell you more info. but IIRC i got the "unexpected error" when i ran the sst command in the wrong directory (where the sst.config.ts was in apps/frontend , but i was running in the main root ), maybe a similar issue?

wenzf commented 1 month ago

@breningham if it's only with dev, and the rest works, it's fully fine for me. All in all SST looks very promising.

Here are some logs:

My guess is that the issue is somewhere here: time=2024-07-16T12:01:04.522+02:00 level=ERROR msg="exited with error" err="failed to connect to mqtt: network Error : websocket: close 1005 (no status)"

sst dev remix vite:dev --verbose
× Unexpected error occurred. Please check the logs or run with --verbose for more details.
secu@secu:~/coding/withsst/ssttry2$ sst dev remix vite:dev --verbose
time=2024-07-16T12:00:56.915+02:00 level=INFO msg="checking for pulumi" path=/XXX/.config/sst/bin/pulumi
time=2024-07-16T12:00:57.038+02:00 level=INFO msg="checking for bun" path=/XXX/.config/sst/bin/bun
time=2024-07-16T12:00:57.045+02:00 level=INFO msg=args args="[remix vite:dev]" length=2
time=2024-07-16T12:00:57.046+02:00 level=INFO msg="starting server"
time=2024-07-16T12:00:57.046+02:00 level=INFO msg="initializing ui" isTTY=true
time=2024-07-16T12:00:57.103+02:00 level=INFO msg="here u go"
time=2024-07-16T12:00:57.103+02:00 level=INFO msg="initialized footer ui"
time=2024-07-16T12:00:57.103+02:00 level=INFO msg="no existing server found, starting new one"
time=2024-07-16T12:00:57.103+02:00 level=INFO msg="waiting for server to start"
time=2024-07-16T12:00:57.151+02:00 level=INFO msg="checking for pulumi" path=/XXX/.config/sst/bin/pulumi
time=2024-07-16T12:00:57.290+02:00 level=INFO msg="checking for bun" path=/XXX/.config/sst/bin/bun                                                                     
time=2024-07-16T12:00:57.292+02:00 level=INFO msg="initializing project" version=0.0.531
time=2024-07-16T12:00:57.292+02:00 level=INFO msg="esbuild building" out=/XXX/.sst/platform/sst.config.123.mjs
time=2024-07-16T12:00:57.295+02:00 level=INFO msg="esbuild built" outfile=/XXX/.sst/platform/sst.config.123.mjs
time=2024-07-16T12:00:57.295+02:00 level=INFO msg="evaluating config"
time=2024-07-16T12:00:57.338+02:00 level=INFO msg="config evaluated"
time=2024-07-16T12:00:57.338+02:00 level=INFO msg="checking platform"
time=2024-07-16T12:00:57.338+02:00 level=INFO msg="checking provider" name=aws version=latest compare=latest
time=2024-07-16T12:00:57.338+02:00 level=INFO msg="loading home"
time=2024-07-16T12:00:57.338+02:00 level=INFO msg="credentials found"
time=2024-07-16T12:00:57.338+02:00 level=INFO msg="fetching bootstrap"
time=2024-07-16T12:00:59.282+02:00 level=INFO msg="found existing bootstrap" data="{\"version\":1,\"asset\":\"sst-asset-XXX\",\"state\":\"sst-state-shfaccmvwxzo\"}"
time=2024-07-16T12:00:59.282+02:00 level=INFO msg="loaded config" app=ssttry2 stage=secu
time=2024-07-16T12:00:59.283+02:00 level=INFO msg=server addr=0.0.0.0:13557
time=2024-07-16T12:00:59.283+02:00 level=INFO msg="getting endpoint"
time=2024-07-16T12:00:59.283+02:00 level=INFO msg=subscribed type=*aws.FunctionInvokedEvent
time=2024-07-16T12:00:59.283+02:00 level=INFO msg=subscribed type=*aws.FunctionResponseEvent
time=2024-07-16T12:00:59.283+02:00 level=INFO msg=subscribed type=*aws.FunctionErrorEvent
time=2024-07-16T12:00:59.283+02:00 level=INFO msg=subscribed type=*aws.FunctionLogEvent
time=2024-07-16T12:00:59.283+02:00 level=INFO msg=subscribed type=*project.StackEvent
time=2024-07-16T12:01:00.614+02:00 level=INFO msg="found endpoint endpoint" url="wss://XXX.iot.XXX.com/mqtt?X-Amz-Expires=86400"
time=2024-07-16T12:01:00.614+02:00 level=INFO msg="signed request" url="wss://XXX.iot.XXX.com/mqtt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=XXX"
time=2024-07-16T12:01:04.522+02:00 level=INFO msg=unsubscribing type=*aws.FunctionLogEvent
time=2024-07-16T12:01:04.522+02:00 level=INFO msg=unsubscribing type=*aws.FunctionResponseEvent
time=2024-07-16T12:01:04.522+02:00 level=INFO msg=unsubscribing type=*aws.FunctionErrorEvent
time=2024-07-16T12:01:04.522+02:00 level=INFO msg=unsubscribing type=*aws.FunctionInvokedEvent
time=2024-07-16T12:01:04.522+02:00 level=INFO msg=unsubscribing type=*project.StackEvent
time=2024-07-16T12:01:04.522+02:00 level=ERROR msg="exited with error" err="failed to connect to mqtt: network Error : websocket: close 1005 (no status)"
× Unexpected error occurred. Please check the logs or run with --verbose for more details.
time=2024-07-16T12:01:04.528+02:00 level=INFO msg="waiting for footer to quit"
time=2024-07-16T12:01:04.529+02:00 level=ERROR msg="exited with error" err="exit status 1"
 sst --version --verbose
sst: deploy anything

  sst init               Initialize a new project
  sst dev [command]      Run in development mode
  sst deploy             Deploy your application
  sst add <provider>     Add a new provider
  sst install            Install all the providers
  sst secret             Manage secrets
  sst shell [command]    Run a command with linked resources
  sst remove             Remove your application
  sst unlock             Clear any locks on the app state
  sst version            Print the version of the CLI
  sst upgrade [version]  Upgrade the CLI
  sst telemetry          Manage telemetry settings
  sst refresh            Refresh the local app state

Learn more at https://ion.sst.dev
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x16f858b]

goroutine 1 [running]:
github.com/sst/ion/cmd/sst/cli.(*Cli).PrintHelp(...)
        /home/runner/work/ion/ion/cmd/sst/cli/cli.go:109
main.run()
        /home/runner/work/ion/ion/cmd/sst/main.go:80 +0x2ab
main.main()
        /home/runner/work/ion/ion/cmd/sst/main.go:41 +0x13c
jayair commented 1 month ago

@wenzf let me ask the team to take a look.

iamandrewluca commented 1 week ago

When we had the sst workshop with Adam, some of the people also encountered this error failed to connect to mqtt me including. I figured it out that it was a problem with the misconfiguration of the AWS Region.

Now I also encountered this issue again when running sst dev My aws cli profile has set region=eu-central-1 my sst config also I changed to region: 'eu-central-1' and got this error.

After setting the export AWS_REGION=eu-central-1 and run sst dev it worked.