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

Add line number context to stack traces when srcrefs are available #133

Merged
merged 7 commits into from
Oct 17, 2019

Conversation

rpkyle
Copy link
Contributor

@rpkyle rpkyle commented Oct 16, 2019

This PR proposes to inspect srcref attributes, when available, for additional context when debug=TRUE and errors are reported in the console or the dev tools UI in-browser. This information is populated in several settings:

  • for internal, packaged functions, when KeepSource is true in the package DESCRIPTION file
  • when applications are interactively loaded via source() and keep.source = TRUE (the default in most cases)
  • when Rscript is used to invoke source at the CLI, and keep.source = TRUE is explicitly provided as an argument to source (since keep.source does not default to TRUE in most cases)

Some function calls will not have srcref attributes populated, and for these no line number is currently displayed. We will continue to investigate whether this functionality can be provided.

The initially proposed implementation looks like this:

image

... and within the dev tools UI, it looks like this:

image

Since there are enclosing environments between the error handler within getStackTrace and the private field to which stack_message is passed, it is necessary to resolve the number of frames to ascend up the stack. The proposed countEnclosingFrames function is an initial attempt at introducing this functionality.

This PR also resolves an issue with the option to display apps within RStudio's viewer pane, and renames that option from viewer to use_viewer.

Closes #132. @chriddyp

@rpkyle rpkyle added parity Modifications to improve parity across Dash implementations dash-stage-in_review dash-type-enhancement labels Oct 16, 2019
@rpkyle rpkyle added this to the Dash v1.5.0 milestone Oct 16, 2019
@rpkyle rpkyle self-assigned this Oct 16, 2019
@rpkyle rpkyle changed the title 132 add line numbers Add line number context to stack traces when srcrefs are available Oct 16, 2019
R/utils.R Outdated Show resolved Hide resolved
R/utils.R Outdated Show resolved Hide resolved
Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fantastic, this will be really useful! 💃 after one small comment.

@rpkyle rpkyle merged commit e8c533a into 125-hot-reloading Oct 17, 2019
@rpkyle rpkyle deleted the 132-add-line-numbers branch October 17, 2019 19:21
rpkyle added a commit that referenced this pull request Nov 1, 2019
* Add line number context to stack traces when srcrefs are available (#133)

* ✨ Support line #s when in debug mode

* ✨ Add use_viewer option for RStudio

* 🚨 Add soft and hard hot reloading tests
@rpkyle rpkyle mentioned this pull request Jan 3, 2020
rpkyle added a commit that referenced this pull request Jan 4, 2020
* Provide support for no_update in Dash for R (#111)

* Use dev_tools_prune_errors instead of pruned_errors (#113)

* Better handling for user-defined error conditions in debug mode (#116)

* Provide support for multiple outputs (#119)

* Provide support for hot reloading in Dash for R (#127)

* Implement support for clientside callbacks in Dash for R (#130)

* Add line number context to stack traces when srcrefs are available (#133)

* Update dash-renderer to 1.2.2 and fix dev tools UI display of stack traces (#137)

* Support for meta tags in Dash for R (#142)

* Fixes for hot reloading interval handling and refreshing apps within viewer pane (#148)

* Support for asynchronous loading/compression in Dash for R (#157)

* Support returning asset URLs via public method within Dash class (#160)

* Minor fix for get_asset_url + docs, add url_base_pathname (#161)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dash-type-enhancement parity Modifications to improve parity across Dash implementations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants