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

print stack traces for panics #271

Merged
1 commit merged into from
Feb 21, 2023
Merged

print stack traces for panics #271

1 commit merged into from
Feb 21, 2023

Conversation

ghost
Copy link

@ghost ghost commented Feb 21, 2023

As with other errors, only print the stack trace if --internalDebug.

This resolves #270. Note that it only affects console output, not analytics tracking.

To test, I added a nil deref in js/express.go:

func (p ExpressHandler) Transform(result *core.CompilationResult, deps *core.Dependencies) error {
	var err error
	_ = err.Error()
	...

Default:

$ klotho . -paws --app ys
Adding resource exec_unit:main
[err 0] runtime error: invalid memory address or nil pointer dereference
Klotho compilation failed

With --internalDebug:

$ klotho . -paws --app ys --internalDebug
Adding resource exec_unit:main
[err 0] runtime error: invalid memory address or nil pointer dereference
github.com/klothoplatform/klotho/pkg/analytics.(*Client).PanicHandler
	/Users/yuval/.klotho/klotho-env/versions/src%2Foss/pkg/analytics/client.go:146
runtime.gopanic
	/opt/homebrew/Cellar/go/1.19.6/libexec/src/runtime/panic.go:890
runtime.panicmem
	/opt/homebrew/Cellar/go/1.19.6/libexec/src/runtime/panic.go:260
runtime.sigpanic
	/opt/homebrew/Cellar/go/1.19.6/libexec/src/runtime/signal_unix.go:835
github.com/klothoplatform/klotho/pkg/lang/javascript.ExpressHandler.Transform
	/Users/yuval/.klotho/klotho-env/versions/src%2Foss/pkg/lang/javascript/express.go:58
github.com/klothoplatform/klotho/pkg/lang/javascript.JavascriptPlugins.Transform
	/Users/yuval/.klotho/klotho-env/versions/src%2Foss/pkg/lang/javascript/plugins.go:34
github.com/klothoplatform/klotho/pkg/core.(*Compiler).Compile
	/Users/yuval/.klotho/klotho-env/versions/src%2Foss/pkg/core/compiler.go:168
github.com/klothoplatform/klotho/pkg/cli.KlothoMain.run
	/Users/yuval/.klotho/klotho-env/versions/src%2Foss/pkg/cli/klothomain.go:404
github.com/spf13/cobra.(*Command).execute
	/Users/yuval/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:916
github.com/spf13/cobra.(*Command).ExecuteC
	/Users/yuval/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:1044
<snip>

Standard checks

  • Unit tests: not unit tested
  • Docs: n/a
  • Backwards compatibility: no issues

As with other errors, only print the stack trace if --internalDebug.

This resolves #270. Note that it only affects console output, not
analytics tracking.
@github-actions
Copy link

Package Line Rate Health
github.com/klothoplatform/klotho/pkg/analytics 3%
github.com/klothoplatform/klotho/pkg/annotation 23%
github.com/klothoplatform/klotho/pkg/cli 4%
github.com/klothoplatform/klotho/pkg/core 21%
github.com/klothoplatform/klotho/pkg/env_var 82%
github.com/klothoplatform/klotho/pkg/exec_unit 54%
github.com/klothoplatform/klotho/pkg/infra/kubernetes 59%
github.com/klothoplatform/klotho/pkg/infra/kubernetes/helm 39%
github.com/klothoplatform/klotho/pkg/input 72%
github.com/klothoplatform/klotho/pkg/lang 38%
github.com/klothoplatform/klotho/pkg/lang/dockerfile 0%
github.com/klothoplatform/klotho/pkg/lang/golang 36%
github.com/klothoplatform/klotho/pkg/lang/javascript 48%
github.com/klothoplatform/klotho/pkg/lang/python 63%
github.com/klothoplatform/klotho/pkg/lang/yaml 0%
github.com/klothoplatform/klotho/pkg/logging 23%
github.com/klothoplatform/klotho/pkg/multierr 95%
github.com/klothoplatform/klotho/pkg/provider/aws 50%
github.com/klothoplatform/klotho/pkg/provider/aws/resources 70%
github.com/klothoplatform/klotho/pkg/runtime 78%
github.com/klothoplatform/klotho/pkg/static_unit 33%
github.com/klothoplatform/klotho/pkg/updater 30%
github.com/klothoplatform/klotho/pkg/validation 74%
github.com/klothoplatform/klotho/pkg/yaml_util 79%
Summary 43% (4253 / 9930)

@ghost ghost merged commit d1516d0 into main Feb 21, 2023
@ghost ghost deleted the panic-in-the-disco branch February 21, 2023 23:08
This pull request was closed.
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

Successfully merging this pull request may close these issues.

panic handler should include full stack trace
1 participant