Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go Panics with improper Cloudflare Setups #387

Open
tallowen opened this issue May 7, 2024 · 6 comments
Open

Go Panics with improper Cloudflare Setups #387

tallowen opened this issue May 7, 2024 · 6 comments
Assignees

Comments

@tallowen
Copy link

tallowen commented May 7, 2024

It seems like there are a couple of issues that can lead to go panics:

  1. Not doing sst add cloudflare
  2. Not adding a CLOUDFLARE_DEFAULT_ACCOUNT_ID

It would be great if the sst cli would output an error message for these. Especially issue 2 on the above list since it's currently not documented.

--- Original Issue Below ---

I'm trying to deploy the default remix app using a custom domain hosted using cloudflare dns. (Now using v0.0.354 everything deploys properly when I don't cloudflare, thanks for addressing #386 !)

My sst.config.ts

/// <reference path="./.sst/platform/config.d.ts" />

export default $config({
  app(input) {
    return {
      name: "my-remix-app",
      removal: input?.stage === "production" ? "retain" : "remove",
      home: "aws",
      providers: { aws: true, cloudflare: true },
    };
  },
  async run() {
    new sst.aws.Remix("MyWeb", {
      domain: {
        name: "owen-remix-test.mydomain.org",
        dns: sst.cloudflare.dns(),
      }
    });
  },
});

Using sst version 0.0.354:

➜  my-remix-app sst deploy --verbose
time=2024-05-07T17:04:18.261-06:00 level=INFO msg="checking for pulumi" path="/Users/ocoutts/Library/Application Support/sst/bin/pulumi"
time=2024-05-07T17:04:18.599-06:00 level=INFO msg="checking for bun" path="/Users/ocoutts/Library/Application Support/sst/bin/bun"
time=2024-05-07T17:04:18.614-06:00 level=INFO msg="initializing project" version=0.0.354
time=2024-05-07T17:04:18.616-06:00 level=INFO msg="esbuild building"
time=2024-05-07T17:04:18.626-06:00 level=INFO msg="esbuild built" outfile=/Users/ocoutts/dev/my-remix-app/.sst/eval/eval-1715123058615.mjs
time=2024-05-07T17:04:18.626-06:00 level=INFO msg="evaluating config"
time=2024-05-07T17:04:18.783-06:00 level=INFO msg="config evaluated"
time=2024-05-07T17:04:18.784-06:00 level=INFO msg="checking platform"
time=2024-05-07T17:04:18.785-06:00 level=INFO msg="checking provider" name=cloudflare version=latest compare=latest
time=2024-05-07T17:04:18.785-06:00 level=INFO msg="checking provider" name=aws version=latest compare=latest
time=2024-05-07T17:04:18.787-06:00 level=INFO msg="credentials found"
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/sst/ion/pkg/project/provider.(*CloudflareProvider).Init(0x140007cecf0, {0x140007ce930?, 0x14000681e69?}, {0x3?, 0x7?}, 0x140007ce780)
	/home/runner/work/ion/ion/pkg/project/provider/cloudflare.go:68 +0x458
github.com/sst/ion/pkg/project.(*Project).LoadHome(0x140001f0000)
	/home/runner/work/ion/ion/pkg/project/project.go:243 +0x19c
main.initProject(0x140001ac5a0)
	/home/runner/work/ion/ion/cmd/sst/main.go:1600 +0x650
main.init.func3(0x140001ac5a0)
	/home/runner/work/ion/ion/cmd/sst/main.go:435 +0x38
main.run()
	/home/runner/work/ion/ion/cmd/sst/main.go:159 +0x6cc
main.main()
	/home/runner/work/ion/ion/cmd/sst/main.go:51 +0x12c

I'm using:

  • An existing coudflare account.
  • A fresh aws accountgm
@markhker
Copy link

markhker commented May 8, 2024

@tallowen Do you have a CLOUDFLARE_DEFAULT_ACCOUNT_ID configured in your env? That does the trick for me

@tallowen
Copy link
Author

tallowen commented May 8, 2024

@markhker - thanks, setting that env variable did indeed fix it!

@ruanmartinelli
Copy link

ruanmartinelli commented May 8, 2024

I had a slightly similar issue with Remix + Cloudflare (exposed Go error).

Logs:

sst deploy --verbose
time=2024-05-08T10:41:19.080-03:00 level=INFO msg="checking for pulumi" path="/Users/ruan/Library/Application Support/sst/bin/pulumi"
time=2024-05-08T10:41:19.390-03:00 level=INFO msg="checking for bun" path="/Users/ruan/Library/Application Support/sst/bin/bun"
time=2024-05-08T10:41:19.407-03:00 level=INFO msg="initializing project" version=0.0.355
time=2024-05-08T10:41:19.407-03:00 level=INFO msg="esbuild building"
time=2024-05-08T10:41:19.409-03:00 level=INFO msg="esbuild built" outfile=/Users/ruan/Desktop/sst-rmx/.sst/eval/eval-1715175679407.mjs
time=2024-05-08T10:41:19.409-03:00 level=INFO msg="evaluating config"
time=2024-05-08T10:41:19.518-03:00 level=INFO msg="config evaluated"
time=2024-05-08T10:41:19.519-03:00 level=INFO msg="checking platform"
panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 1 [running]:
github.com/sst/ion/pkg/project.(*Project).NeedsInstall(0x140000fc600)
	/home/runner/work/ion/ion/pkg/project/install.go:25 +0x29c
main.initProject(0x140006d20f0)
	/home/runner/work/ion/ion/cmd/sst/main.go:1591 +0x574
main.init.func3(0x140006d20f0)
	/home/runner/work/ion/ion/cmd/sst/main.go:435 +0x38
main.run()
	/home/runner/work/ion/ion/cmd/sst/main.go:159 +0x6cc
main.main()
	/home/runner/work/ion/ion/cmd/sst/main.go:51 +0x12c

sst.config.ts:

export default $config({
  app(input) {
    return {
      name: "sst-remix",
      removal: input?.stage === "production" ? "retain" : "remove",
      home: "cloudflare",
    };
  },
  async run() {
    new sst.cloudflare.Remix("MyWeb");
  },
});

The issue is that I didn't install the Cloudflare provider (obvious I know, but I'm new to SST and the docs don't mention that). Only the AWS provider is installed by default on sst init.

sst add cloudflare solved it for me, posting it in case it helps anyone.

@tallowen tallowen changed the title Go Panic on sst deploy using remix + cloudflare dns Go Panics with improper Cloudflare Setups May 8, 2024
Copy link
Contributor

thdxr commented May 8, 2024

is this still an issue in the latest sst? thought i handled the case when there's no account id able to be inferred

@tallowen
Copy link
Author

tallowen commented May 8, 2024

@thdxr - should version 0.0.354 have the fix? That version (I believe from yesterday) does have at least the issue when CLOUDFLARE_DEFAULT_ACCOUNT_ID is not set.

@rlcurrall
Copy link

I'm getting a slightly different error, not sure if it is related to this or not. I cloned the ion repo and tried running the cloudflare-remix example, added a .env file with the CLOUDFLARE_API_TOKEN and CLOUDFLARE_DEFAULT_ACCOUNT_ID values set.

Error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x15ac83b]goroutine 107 [running]:
github.com/sst/ion/pkg/project.(*stack).Run(0xc00098c080, {0x2ae8308, 0xc000b5c5a0}, 0xc00079bcc0)
	/home/runner/work/ion/ion/pkg/project/stack.go:535 +0x347b
github.com/sst/ion/pkg/server.startDeployer.func2()
	/home/runner/work/ion/ion/pkg/server/deployer.go:33 +0x166
created by github.com/sst/ion/pkg/server.startDeployer in goroutine 1
	/home/runner/work/ion/ion/pkg/server/deployer.go:30 +0x1b9
Verbose logs
time=2024-05-18T13:21:35.830-04:00 level=INFO msg="checking for pulumi" path=/home/robb/.config/sst/bin/pulumi
time=2024-05-18T13:21:36.004-04:00 level=INFO msg="checking for bun" path=/home/robb/.config/sst/bin/bun
time=2024-05-18T13:21:36.010-04:00 level=INFO msg=args args="[remix dev]" length=2
time=2024-05-18T13:21:36.010-04:00 level=INFO msg="connecting to server" addr=0.0.0.0:13557
time=2024-05-18T13:21:36.011-04:00 level=INFO msg="no existing server found, starting new one"
time=2024-05-18T13:21:36.011-04:00 level=INFO msg="waiting for server to start"
time=2024-05-18T13:21:36.039-04:00 level=INFO msg="checking for pulumi" path=/home/robb/.config/sst/bin/pulumi
time=2024-05-18T13:21:36.184-04:00 level=INFO msg="checking for bun" path=/home/robb/.config/sst/bin/bun
time=2024-05-18T13:21:36.186-04:00 level=INFO msg="initializing project" version=0.0.373
time=2024-05-18T13:21:36.186-04:00 level=INFO msg="esbuild building"
time=2024-05-18T13:21:36.189-04:00 level=INFO msg="esbuild built" outfile=/home/robb/Code/ion/examples/cloudflare-remix/.sst/eval/eval-1716052896186.mjs
time=2024-05-18T13:21:36.189-04:00 level=INFO msg="evaluating config"
time=2024-05-18T13:21:36.226-04:00 level=INFO msg="config evaluated"
time=2024-05-18T13:21:36.226-04:00 level=INFO msg="checking platform"
time=2024-05-18T13:21:36.226-04:00 level=INFO msg="checking provider" name=cloudflare version=latest compare=latest
time=2024-05-18T13:21:36.226-04:00 level=INFO msg="cloudflare account selected" account=20345ff0f6029a679752211d8c3acfdd
time=2024-05-18T13:21:37.598-04:00 level=INFO msg="found existing bucket" bucket=sst-state
time=2024-05-18T13:21:37.598-04:00 level=INFO msg="loaded config" app=cloudflare-remix stage=robb
time=2024-05-18T13:21:37.599-04:00 level=INFO msg=server addr=0.0.0.0:13557
time=2024-05-18T13:21:37.599-04:00 level=INFO msg=subscribed type=*project.StackEvent
time=2024-05-18T13:21:37.599-04:00 level=INFO msg=subscribed type=*watcher.FileChangedEvent
time=2024-05-18T13:21:37.599-04:00 level=INFO msg=subscribed type=*aws.FunctionInvokedEvent
time=2024-05-18T13:21:37.599-04:00 level=INFO msg=subscribed type=*aws.FunctionResponseEvent
time=2024-05-18T13:21:37.599-04:00 level=INFO msg=subscribed type=*aws.FunctionErrorEvent
time=2024-05-18T13:21:37.599-04:00 level=INFO msg=subscribed type=*aws.FunctionLogEvent
time=2024-05-18T13:21:37.599-04:00 level=INFO msg=subscribed type=*project.StackEvent
time=2024-05-18T13:21:37.599-04:00 level=INFO msg=watching path=/home/robb/Code/ion/examples/cloudflare-remix
time=2024-05-18T13:21:37.599-04:00 level=INFO msg=watching path=/home/robb/Code/ion/examples/cloudflare-remix/app
time=2024-05-18T13:21:37.599-04:00 level=INFO msg=watching path=/home/robb/Code/ion/examples/cloudflare-remix/app/routes
time=2024-05-18T13:21:37.600-04:00 level=INFO msg=watching path=/home/robb/Code/ion/examples/cloudflare-remix/public
time=2024-05-18T13:21:37.601-04:00 level=INFO msg=subscribed type=*watcher.FileChangedEvent
time=2024-05-18T13:21:37.601-04:00 level=INFO msg=subscribed type=*server.DeployRequestedEvent
time=2024-05-18T13:21:37.601-04:00 level=INFO msg=subscribed type=*project.StackEvent
time=2024-05-18T13:21:37.601-04:00 level=INFO msg="running stack command" cmd=uptime=2024-05-18T13:21:37.601-04:00 level=INFO msg=publishing type=*project.StackEvent
time=2024-05-18T13:21:37.601-04:00 level=INFO msg=publishing type=*watcher.FileChangedEventtime=2024-05-18T13:21:37.601-04:00 level=INFO msg="INFO locking app=cloudflare-remix stage=robb"
time=2024-05-18T13:21:37.601-04:00 level=INFO msg="INFO getting data key=lock app=cloudflare-remix stage=robb"time=2024-05-18T13:21:37.618-04:00 level=INFO msg="connecting to server" addr=0.0.0.0:13557time=2024-05-18T13:21:37.619-04:00 level=INFO msg=subscribed addr=127.0.0.1:38286time=2024-05-18T13:21:37.619-04:00 level=INFO msg=subscribed type=*aws.FunctionInvokedEventtime=2024-05-18T13:21:37.619-04:00 level=INFO msg=subscribed type=*aws.FunctionResponseEvent
time=2024-05-18T13:21:37.619-04:00 level=INFO msg=subscribed type=*aws.FunctionErrorEventtime=2024-05-18T13:21:37.619-04:00 level=INFO msg=subscribed type=*aws.FunctionLogEvent
time=2024-05-18T13:21:37.619-04:00 level=INFO msg=subscribed type=*project.StackEventtime=2024-05-18T13:21:37.619-04:00 level=INFO msg=subscribed type=*aws.FunctionBuildEventtime=2024-05-18T13:21:37.619-04:00 level=INFO msg=subscribed type=*cloudflare.WorkerBuildEvent
time=2024-05-18T13:21:37.619-04:00 level=INFO msg=subscribed type=*cloudflare.WorkerUpdatedEventtime=2024-05-18T13:21:37.619-04:00 level=INFO msg=subscribed type=*cloudflare.WorkerInvokedEvent
time=2024-05-18T13:21:37.622-04:00 level=INFO msg="got server stream"time=2024-05-18T13:21:37.624-04:00 level=INFO msg="file event" path=/home/robb/Code/ion/examples/cloudflare-remix/out.txt op=WRITE
time=2024-05-18T13:21:37.624-04:00 level=INFO msg=publishing type=*watcher.FileChangedEvent
time=2024-05-18T13:21:37.624-04:00 level=INFO msg="file event" path=/home/robb/Code/ion/examples/cloudflare-remix/out.txt op=WRITEtime=2024-05-18T13:21:37.624-04:00 level=INFO msg="file event" path=/home/robb/Code/ion/examples/cloudflare-remix/out.txt op=WRITE
time=2024-05-18T13:21:37.624-04:00 level=INFO msg="file event" path=/home/robb/Code/ion/examples/cloudflare-remix/out.txt op=WRITEtime=2024-05-18T13:21:37.625-04:00 level=INFO msg="file event" path=/home/robb/Code/ion/examples/cloudflare-remix/out.txt op=WRITEtime=2024-05-18T13:21:37.625-04:00 level=INFO msg="file event" path=/home/robb/Code/ion/examples/cloudflare-remix/out.txt op=WRITEtime=2024-05-18T13:21:38.101-04:00 level=INFO msg=publishing type=*watcher.FileChangedEventtime=2024-05-18T13:21:38.519-04:00 level=INFO msg="INFO putting data key=lock app=cloudflare-remix stage=robb"time=2024-05-18T13:21:38.601-04:00 level=INFO msg=publishing type=*watcher.FileChangedEventtime=2024-05-18T13:21:39.101-04:00 level=INFO msg=publishing type=*watcher.FileChangedEvent
time=2024-05-18T13:21:39.380-04:00 level=INFO msg="INFO pulling state app=cloudflare-remix stage=robb out=/home/robb/Code/ion/examples/cloudflare-remix/.sst/.pulumi/stacks/cloudflare-remix/robb.json"
time=2024-05-18T13:21:39.601-04:00 level=INFO msg=publishing type=*watcher.FileChangedEvent
time=2024-05-18T13:21:40.101-04:00 level=INFO msg=publishing type=*watcher.FileChangedEvent
time=2024-05-18T13:21:40.362-04:00 level=INFO msg="INFO getting passphrase app=cloudflare-remix stage=robb"time=2024-05-18T13:21:40.601-04:00 level=INFO msg=publishing type=*watcher.FileChangedEventtime=2024-05-18T13:21:41.065-04:00 level=INFO msg="INFO getting data key=secret app=cloudflare-remix stage=robb"time=2024-05-18T13:21:41.101-04:00 level=INFO msg=publishing type=*watcher.FileChangedEventtime=2024-05-18T13:21:41.601-04:00 level=INFO msg=publishing type=*watcher.FileChangedEventtime=2024-05-18T13:21:41.897-04:00 level=INFO msg="esbuild building"
time=2024-05-18T13:21:41.952-04:00 level=INFO msg="esbuild built" outfile=/home/robb/Code/ion/examples/cloudflare-remix/.sst/platform/eval/eval-1716052901897.mjs
time=2024-05-18T13:21:41.957-04:00 level=INFO msg="files changed" files=127
time=2024-05-18T13:21:41.957-04:00 level=INFO msg="tracked files"
time=2024-05-18T13:21:42.101-04:00 level=INFO msg=publishing type=*watcher.FileChangedEventtime=2024-05-18T13:21:42.122-04:00 level=INFO msg="built workspace"
time=2024-05-18T13:21:42.304-04:00 level=INFO msg="built stack"time=2024-05-18T13:21:42.479-04:00 level=INFO msg="built config"
time=2024-05-18T13:21:42.479-04:00 level=INFO msg="running stack command" cmd=up
time=2024-05-18T13:21:42.480-04:00 level=INFO msg="stack command complete"
time=2024-05-18T13:21:42.601-04:00 level=INFO msg=publishing type=*watcher.FileChangedEventtime=2024-05-18T13:21:43.101-04:00 level=INFO msg=publishing type=*watcher.FileChangedEvent
time=2024-05-18T13:21:43.244-04:00 level=INFO msg=publishing type=*project.StackEventtime=2024-05-18T13:21:43.244-04:00 level=INFO msg="INFO pushing state app=cloudflare-remix stage=robb from=/home/robb/Code/ion/examples/cloudflare-remix/.sst/.pulumi/stacks/cloudflare-remix/robb.json"
time=2024-05-18T13:21:43.245-04:00 level=INFO msg="file event" path=/home/robb/Code/ion/examples/cloudflare-remix/out.txt op=WRITE
time=2024-05-18T13:21:43.245-04:00 level=INFO msg=publishing type=*watcher.FileChangedEventtime=2024-05-18T13:21:43.245-04:00 level=INFO msg=done addr=127.0.0.1:38286
time=2024-05-18T13:21:43.245-04:00 level=INFO msg="file event" path=/home/robb/Code/ion/examples/cloudflare-remix/out.txt op=WRITE
time=2024-05-18T13:21:43.245-04:00 level=INFO msg="file event" path=/home/robb/Code/ion/examples/cloudflare-remix/out.txt op=WRITE
time=2024-05-18T13:21:43.245-04:00 level=INFO msg=unsubscribing type=*aws.FunctionInvokedEvent
time=2024-05-18T13:21:43.245-04:00 level=INFO msg=unsubscribing type=*cloudflare.WorkerInvokedEvent
time=2024-05-18T13:21:43.245-04:00 level=INFO msg=unsubscribing type=*aws.FunctionLogEvent
time=2024-05-18T13:21:43.245-04:00 level=INFO msg=unsubscribing type=*cloudflare.WorkerUpdatedEvent
time=2024-05-18T13:21:43.245-04:00 level=INFO msg="cleaning up deployer"
time=2024-05-18T13:21:43.245-04:00 level=INFO msg=unsubscribing type=*cloudflare.WorkerBuildEvent
time=2024-05-18T13:21:43.245-04:00 level=INFO msg=unsubscribing type=*project.StackEvent
time=2024-05-18T13:21:43.245-04:00 level=INFO msg=unsubscribing type=*aws.FunctionResponseEvent
time=2024-05-18T13:21:43.245-04:00 level=ERROR msg="exited with error" err="http: read on closed response body"
time=2024-05-18T13:21:43.245-04:00 level=INFO msg=unsubscribing type=*aws.FunctionBuildEvent
time=2024-05-18T13:21:43.245-04:00 level=INFO msg=unsubscribing type=*aws.FunctionErrorEvent
time=2024-05-18T13:21:43.245-04:00 level=INFO msg=unsubscribing type=*aws.FunctionErrorEvent
time=2024-05-18T13:21:43.245-04:00 level=INFO msg=unsubscribing type=*project.StackEvent
time=2024-05-18T13:21:43.245-04:00 level=INFO msg=unsubscribing type=*aws.FunctionLogEvent
time=2024-05-18T13:21:43.245-04:00 level=INFO msg=unsubscribing type=*server.DeployRequestedEvent
time=2024-05-18T13:21:43.245-04:00 level=INFO msg=unsubscribing type=*watcher.FileChangedEvent
time=2024-05-18T13:21:43.245-04:00 level=INFO msg=unsubscribing type=*aws.FunctionInvokedEvent
time=2024-05-18T13:21:43.245-04:00 level=INFO msg=unsubscribing type=*project.StackEvent
time=2024-05-18T13:21:43.245-04:00 level=INFO msg=unsubscribing type=*aws.FunctionResponseEvent
time=2024-05-18T13:21:43.245-04:00 level=INFO msg=unsubscribing type=*project.StackEvent
time=2024-05-18T13:21:43.245-04:00 level=INFO msg=unsubscribing type=*watcher.FileChangedEvent
time=2024-05-18T13:21:44.354-04:00 level=INFO msg="INFO unlocking app=cloudflare-remix stage=robb"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x15ac83b]goroutine 107 [running]:
github.com/sst/ion/pkg/project.(*stack).Run(0xc00098c080, {0x2ae8308, 0xc000b5c5a0}, 0xc00079bcc0)
	/home/runner/work/ion/ion/pkg/project/stack.go:535 +0x347b
github.com/sst/ion/pkg/server.startDeployer.func2()
	/home/runner/work/ion/ion/pkg/server/deployer.go:33 +0x166
created by github.com/sst/ion/pkg/server.startDeployer in goroutine 1
	/home/runner/work/ion/ion/pkg/server/deployer.go:30 +0x1b9
Cloudflare API Token Summary

image

Hopefully that is helpful information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants