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

Send existing stacktrace from paniced Eval to the configured interp.Options.Stderr #1030

Closed
TheMightyGit opened this issue Feb 3, 2021 · 1 comment · Fixed by #1039
Closed
Labels
area/core enhancement New feature or request
Milestone

Comments

@TheMightyGit
Copy link
Contributor

TheMightyGit commented Feb 3, 2021

Proposal

At the moment (0.9.11) the stacktrace when an Eval panics goes only to the apps fmt.Println() and not to the configured interp.Options.Stderr. This makes it hard to capture the stack trace when you wish to surface that info to somewhere other than the apps stdout.

If yaegi also printed the stacktrace to the configured interp.Options.Stderr it would make it possible for me to consume it, and logically it makes sense to me that the stacktrace would appear in the scripts configured Stderr.

I believe this is the line that prints it - https://github.com/traefik/yaegi/blob/master/interp/run.go#L182

Background

I recover() from Eval panics and wish to show the existing stacktrace (that only seems to go to the apps stdout) to the user in the GUI.

Workarounds

I could not find one, but maybe I missed another way of getting the stacktrace from a panic'ed eval?

I am also compiling for JS/WASM where os.Pipe() is not available, so I cannot simply replace and consume main apps Stdout/err to get the stacktrace when the Eval panics.

@TheMightyGit TheMightyGit changed the title Send stacktrace from paniced Eval to the configured interp.Options.Stderr Send existing stacktrace from paniced Eval to the configured interp.Options.Stderr Feb 3, 2021
@tigerwill90
Copy link
Contributor

I think fmt.Println() is here only for testing purpose according to https://github.com/traefik/yaegi/blob/master/interp/interp.go#L210

@mvertes mvertes added the enhancement New feature or request label Feb 20, 2021
@mvertes mvertes added this to the v0.9.x milestone Feb 20, 2021
traefiker pushed a commit that referenced this issue Feb 20, 2021
As mentioned in #1030, when an Eval panic, it is print with `fmt.Println()` and not to the configured `interp.Options.Stderr`. According to https://github.com/traefik/yaegi/blob/master/interp/interp.go#L210, it should be removed in future version so I'm not sure if this pull request is necessary. However, it could fix the issue in the meanwhile.

Fixes #1030.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants