I assume you're also on a Windows machine? And it's not quite the same issue, since the post you link to refers to version 4.2. I've not experienced the issue myself, since I've been doing most of my work on Linux systems, recently, and hence had not updated my Windows RStudio for a while. Now that I've updated to Build 485 (still running R version 4.1.2 at this point), I've not managed to reproduce your issue, but spotted some odd behavior on the end of a session. See the following figure:
Immediately upon closing RStudio or quitting the session, an error message appears in the R console, stating that R could not write to ~/.Rhistory because access denied. The error was also logged in C:\Users{Your Username}\AppData\Local\RStudio\log\rsession-{Your Username}.log
There's also the following warning:
WARNING findProgramOnPath returns wrong result: C:\texlive\2021\bin\win32\pdflatex.exe != C:/texlive/2021/bin/win32/pdflatex.exe;
That one's odd because, on a Windows system, it seems to be looking for a path with slashes rather than backslashes.
To me it looks like the newest version of RStudio does not handle Windows paths correctly, since the logged errors show paths with '/' instead of ''. The issue does not seem related to R, since R can perfectly handle such paths, but I don't know about RStudio. Furthermore, this would explain why everyone with this issue appears to be using Windows.
So assuming that the issue is actually related to RStudio, what can you do? I'm afraid not much apart from waiting for a patch. However, since saving seems to work fine on my end, you could try to work with R Projects in the meantime and use version control (git) to ensure that you can quickly restore any lost work.
Edit: Here's the full error message with minor formatting.
2022-05-25T14:51:57.489827Z [rsession-thoma]
ERROR system error 5 (Zugriff verweigert) [path: C:/Users/thoma/Documents/.Rhistory];
OCCURRED AT
auto __cdecl rstudio::core::FilePath::openForWrite::
<lambda_ee6056efa5463874f96f1d4ce6e5cdd4>::operator ()(void) const
src/cpp/shared_core/FilePath.cpp:1498;
LOGGED FROM:
void __cdecl rstudio::r::session::reportHistoryAccessError(
const class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char>> &,
const class rstudio::core::FilePath &, const class rstudio::core::Error &)
src/cpp/r/session/RInit.cpp:403
Edit 2: Upgraded to R version 4.2 and still could not reproduce issue. Can you provide any additional details (for example whether your username contains any special characters, or whether certain paths contain whitespace, what you mean by logging off, and so on).
Also, can you try to open your R file in a different editor (even notepad.exe will do) while RStudio is running and after you've saved the file to check whether the code is actually saved to disk?