Skip to content

Stack traces do not render in the dev tools UI when using RStudio's viewer pane #994

@rpkyle

Description

@rpkyle

RStudio's IDE does not allow embedding of iframe elements which include content from "external" URLs, as noted in rstudio/rstudioapi#2.

The way that dash-renderer currently handles stack traces places them into an iframe so that Werkzeug's CSS doesn't affect the display of the rest of the page:

{typeof error.html !== 'string' ? null : (
<div className="dash-be-error__st">
<div className="dash-backend-error">
{/* Embed werkzeug debugger in an iframe to prevent
CSS leaking - werkzeug HTML includes a bunch
of CSS on base html elements like `<body/>`
*/}
<iframe
srcDoc={error.html
.replace(
'</head>',
`<style type="text/css">${werkzeugCss}</style></head>`
)
.replace(
'="?__debugger__',
`="${base}?__debugger__`
)}
style={{
/*
* 67px of padding and margin between this
* iframe and the parent container.
* 67 was determined manually in the
* browser's dev tools.
*/
width: 'calc(600px - 67px)',
height: '75vh',
border: 'none',
}}
/>
</div>
</div>
)}

This has the unfortunate consequence of showing no stack trace within RStudio, though it appears properly in standalone browsers:

image

The plot_ly function gets around this problem by embedding source from localhost, which is allowed:

<iframe class="gwt-Frame ace_editor_theme" src="http://localhost:29325/session/viewhtml98b753d4ffc6/index.html?viewer_pane=1" style="width: 100%; height: 100%; position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px; background-color: rgb(255, 255, 255);"></iframe>

We can preserve the existing behaviour in the renderer for Python apps by implementing a condition which checks whether the content of the stack trace begins with <!DOCTYPE HTML>, then enclose in an iframe if true.

Dash for R would then be modified to send back a stack trace that is raw text, which the renderer will insert directly within <pre> tags (since the above condition would be false), and this should enable support for stack trace display in the RStudio viewer as well as standalone browsers.

@alexcjohnson

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions