A bad practice that broke ReactLog and ctx$invalidate

I have been using R and Shiny for a few years now and have built a fairly large capacity modeling tool that allows my employer to forecast and model incoming testing volumes to understand how we need to adjust our headcount or equipment utilization.

A few months ago I realized that I was not able to view the reactlog for my app. Data was being loaded in, but nothing was being displayed on the graph (toolbars, etc. worked, but the screen was white). Later, I found that one part of the tool, where a user could build out "contracts" to load in custom volume numbers was causing some instability when built in one session and then modified in another. When running the app locally it started to throw an error of "Warning: Error in ctx$invalidate: Reactive context was created in one process and invalidated from another." when I tried to open and resave the contracts module. I should note that I was running this off a small local Shiny server to allow for data persistence for the various tables that were fed into this system.

Long story short, while most of my tables were built as individual tables that could be saved as RDS (and loaded back from RDS), the "Contracts" table was a reactiveValues object that I had saved to an RDS file. THIS IS A MISTAKE!

The reactiveValues had five variables stored to it, each taking about 1-3KB of space. The RDS of the whole reactiveValues ballooned to 11MB! Saving new values into the reactiveValues would frequently throw the above ctx$invalidate errors and was the cause of my reactlog graphs breaking, as loading the RDS brought along reactive context that reactlog was not able to build connections to (as they were named in the environment/context where the reactiveValue was first created).

I solved this by generating an empty reactiveValues and loading in the variables separately (from readRDS), which fixed both issues.