Loading spinner (hourglass) in my shiny app only appears to first user when app is accessed by multiple users

I am building an R Shiny application where I need to show a loading spinner (hourglass) when an action button is clicked. The spinner should appear across all tabs and should work independently for multiple users concurrently.


The initial implementation worked for a single user but did not function correctly when multiple users accessed the application simultaneously. Specifically, the loading spinner did not appear for the second user if they clicked the start button while the spinner was still active for the first user.

Steps Taken and Issues Encountered:

  1. Initial Implementation:
  • Used shinyjs to control the visibility of the spinner.
  • JavaScript custom message handlers were added to show/hide the spinner.
  • The spinner worked for a single user but failed for concurrent users.
  1. Troubleshooting and Debugging:
  • Verified that custom.js was loaded correctly.
  • Ensured messages were being sent and received correctly between the server and client.
  1. Updated Implementation:
  • Included session-specific message handling to ensure each user's spinner was controlled independently.
  • Despite these changes, the spinner still did not function correctly for multiple concurrent users.
  1. Final Attempt with shinyjs Extend:
  • Attempted to use extendShinyjs to define custom JavaScript functions directly within the Shiny app.
  • Faced issues with the proper implementation of extendShinyjs, leading to errors.