Repository navigation
Description
I'm using a package of learnr tutorials for teaching that I wrote (https://github.com/profandyfield/discovr ).
Some students intermitently get the following error when the click 'start tutorial'.
Error: parse error: trailing garbage
":{},"value":["0.10.1"]}]}]} {"type":"list","attributes":{},
(right here) ------^
Execution halted
I had similar issues last year as well which remained unresolved. I can't post a reporducible example because we can't reporduce it: We can't see any consistent predictors of when it happens or for whom. It feels impossible to debug but I also don't really understand the process of what happens when someone clicks the 'start tutorial' button (other than it reneders my RMD into a tutortial ... or how it uses a stored html file when a tutorial starts or how a stored html might become corrupt.
We have students who, for example, load a tutorial successfully using the RStudio tutorials pane, but then next time they load it they get this error. Based on my explorations last year I assume it's an error with the html renedering. Consistent with this assumption if we (a) manually delete the html of the problematic tutorial from the package library on their system, or (b) force a reinstall (which would also clear the html files) the problem goes away. However, it can return (for the same student).
I don't know if this is a bug, and I appreciate (really I do having tried to workiit out for over a year) how impossible it is to have a solution when we can't reliably reproduce the issue, but I would really appreciate some pointers about why this might be happening - like, some options to explore or some better understanding of the rendering process and why it might fail when it has succeeded before. Could this be down to user input in a previous session using the tutorial? Could it be to do with strange text in my hints? Is there something I can do within the tutorial to prevent it (I currently don't error catch any code that students type into exercises). Any useful pointers?
Activity
gadenbuie commentedon Oct 13, 2021
Two related RStudio Community posts:
gadenbuie commentedon Oct 13, 2021
From
"value":["0.10.1"]I'm guessing that this student has learnr version 0.10.1 installed (the current version on CRAN). An easy first place to start would be to find out if the problem goes away when students use the latest version of learnr from GitHub. Beyond that, it would be helpful to know which version of rmarkdown is in use; that error likely comes from rmarkdown's shiny prerendered dependency resolution. If rmarkdown is out of date, it may be a bug that has since been fixed. In short, if you could ask the students to capture their session info usingdevtools::session_info()when the error occurs, that could provide some important initial clues.profandyfield commentedon Oct 13, 2021
It's miltiple students. We tell students to update to the lastest Rstudio (which should update Markdown shouldn't it?), so that's what they should be running. Anbd yes, they'd have the latest learnr from CRAN because we can't build from source in university computer labs (at least not easily) so we have to try to stick with CRAN packages. I can ask my tutors to get
sessionInfo()when this happens again. If it is down to rmarkdown's shiny prerendered dependency resolution, is there a way I could test that by breaking it myself - could you give me an example of something that would break the tutorial so I can try to do that and report back more specific information?gadenbuie commentedon Oct 13, 2021
Yes, asking for
sesionInfo()would be a big help; without knowing specific package versions it's a very large haystack.Another thing that could be helpful would be to send me the prerendered HTML file for the tutorial. When the error arises, you could ask the user (possibly with the tutor's help) to find the
discovr_XX.htmlfile and send it to you to share here.bwagner commentedon Oct 20, 2021
Total newbie here. I consistently get the error when trying to run tutorial "Filter observations". Here's the output of
sessionInfo():In @gadenbuie 's suggestion, I didn't know what
XXindisvovr_XXwas supposed to be replaced with. (As mentioned above, the tutorial acting up was "Filter observations").However, the problem disappeared after issuing
remove.packages('learnr')and subsequentlyinstall.packages('learnr')in RStudio's Console.gadenbuie commentedon Oct 21, 2021
@bwagner The
discovr_XXbit is relevant for thediscovrpackage specifically, but you'd need something a little more general. For tutorials that are provided by packages, they must be installed in the "tutorials" folder of the package. You can find that folder usingsystem.file():and then you can look in that folder to see the list of tutorials
or find the folder for a specific tutorial
If you can reliably reproduce this issue with the Filter observations tutorial, would you mind following the steps above and sharing the
.htmlfile? Thanks!profandyfield commentedon Oct 21, 2021
Attached is a zip file containing three recent cases. Each case I include the pre-renedered html file and the session info. I hope this is useful.
lexical_errors.zip
profandyfield commentedon Oct 22, 2021
added two more cases, case 5 includes 2 html files from sequential failures. Updated RStudio and it rendered after that
lexical_errors.zip
.
eleanorbath commentedon Oct 28, 2021
Hi, @profandyfield, we had the same issue publishing to an RStudio Connect server (exact same error messages). Everything worked fine last year, but this year we couldn't publish anything (even ones that worked last year). We found that the issue was the latest version of RStudio that we were publishing from - if we downgraded from that, we didn't have the issues any more. Our errors popped up every time though, so I guess slightly different. Not sure if that's helpful, but you are not alone!
profandyfield commentedon Nov 26, 2021
we've been collecting some of these errors throughout term (this is not exhaustive by the way, just a selection of instances where we've been around to collect the failing html file and the session Info). There's now 15 cases (the first 5 cases are the same as those that I posted on Oct 22nd). I'm happy to keep stockpiling these if it's useful, but if it's not let me know and I'll stop
lexical_errors_2021_26.zip
!
yassinza commentedon Jul 18, 2023
Hi @profandyfield , were you able to solve this? we are facing a similar issues on shinyapps. thanks!
yassinza commentedon Jul 19, 2023
Hi @gadenbuie , me again :) We started facing this issue when we upgraded from free to the basic plan and started changing the setting for the app ( maybe not related, but worth mentioning).
We see this error happen after the app goes to sleep for some time and then we try to access it. any pointers on this, please? thanks!
gadenbuie commentedon Jul 19, 2023
Hi @yassinza – I've spent quite a while looking into this on many occasions. I have some theories, but the fact that I haven't been able to reliably reproduce it has been a major hinderance.
Would you be able to send me the
.htmlversion of your tutorial from the application bundle (or even just the whole bundle) the next time this happens? In the https://shinyapps.io dashboard, open your tutorial application and on the Overview page in the left column there's a button to download the Bundle. You can email me the archive or you can extract the.htmlfile in it. My email is [email protected].gadenbuie commentedon Jul 20, 2023
One thing that might work to help avoid this is to set the
RMARKDOWN_RUN_PRERENDERenvironment variable to"1". This would, ideally, cause rmarkdown to re-render the tutorial anew every time it starts up. I recognize that's not ideal, but it seems that the issue occurs when the pre-rendered output of previously rendered tutorial is reused to speed up the app startup. In shinyapps.io, I believe you can deploy your app with an adjacent.Renvironwith the entry(If that does help, please let me know. That information will help isolate the bug.)
gadenbuie commentedon Jul 20, 2023
Hi all. Thank you very much to everyone in this thread for your help with this bug. In particular thank you @profandyfield and @yassinza for providing example files.
My apologies that this took so long to track down, but in returning to this issue with fresh eyes I found a new thread to pull and I think I understand why the bug is happening (but I still don't entirely know how this is happening).
In rstudio/rmarkdown#2499 I've outlined the mechanics of the bug as I understand it, and in rstudio/rmarkdown#2500 I've provided a work-around that at least avoids the crash on app startup. If you can try that PR, I'd appreciate it.
yassinza commentedon Jul 21, 2023
Thanks a lot @gadenbuie!
I tried both:
It was there before also, and seems to happen right before the parsing error.
As agreed I will open a support ticket at this point, thanks a lot!
yassinza commentedon Jul 25, 2023
Hi @gadenbuie , I Just wanted to update you on this. We are using both fixes together now.
This is the error we see:
The app works fine upon refreshing the page though. Thanks!
mbaynton commentedon Jul 28, 2023
So I think there must be two root causes here that are different depending on whether the tutorial is running under RStudio or under connect. We'll still need to research @yassinza's connect/shinyapps.io variant, but the RStudio one is probably this:
You can reproduce this most of the time by running on a remote instance of RStudio so that there is some network latency involved, and double-clicking on the
Start Tutorialbutton. Each click launches an rmarkdown render.If you're running locally, the button is removed too quickly for the second click to be registered.
@gadenbuie gets most of the credit for identifying that the error message is caused by a corrupted html file and that one way to generate such a file is to render it twice concurrently. All I really did from there was think like a user 😁
mbaynton commentedon Aug 1, 2023
We've continued to pursue this and there are now bugs open in Connect, RStudio Server, and
rmarkdown. Thank you for your patience!yassinza commentedon Aug 2, 2023
Thanks a lot! Let me know if I can help in any way.
profandyfield commentedon Aug 2, 2023
Sorry for my silence - just got back from leave. We switched to teaching with posit cloud this year instead of a campus-install of RStudio run over a network via a software hub and we've had hardly any (maybe none?) of these errors. I think this corroborates the network latency/double click explanation of the error because when we used the software hub RStudio we had endless issues with the network connection between the users PC and Rstudio being slow that we just don't get with posit cloud. Anyway, thought this info might be worth sharing.