-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Avoid throwing errors for shared input/output IDs #4101
Open
gadenbuie
wants to merge
19
commits into
main
Choose a base branch
from
feat/client-message-event
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+485
−293
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Now that it's not an error, it's safe to report
It's otherwise hard to tell that the error is scrollable Plus the scrolling is over the whole message rather than the part that overflows
gadenbuie
changed the title
feat: Avoid throwing binding validity errors
feat: Avoid throwing binding validity errors for shared input/output IDs
Jul 15, 2024
gadenbuie
changed the title
feat: Avoid throwing binding validity errors for shared input/output IDs
feat: Avoid throwing errors for shared input/output IDs
Jul 15, 2024
jcheng5
reviewed
Sep 30, 2024
jcheng5
reviewed
Sep 30, 2024
jcheng5
reviewed
Sep 30, 2024
jcheng5
reviewed
Sep 30, 2024
jcheng5
approved these changes
Sep 30, 2024
* Renamed `showMessageInClientConsole()` to `showShinyClientMessage()` to improve clarity * Added `status` argument to `showShinyClientMessage()` to allow for different message types
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4100
Description
This PR refactors the Shiny Client Error console to allow client error messages to be communicated via events in addition to errors.
The primary goal is to avoid throwing an error from the binding validity checks for shared input/output ID errors. In practice, there were two problems with the binding validity checks throwing errors:
There are many cases where an app with shared IDs may still work, but by throwing an error we guarantee that the app breaks. Because we throw the error from Shiny's initialization code, we absolutely guarantee the app will not work, even if in practice the ID collision would not have caused problems.
We were previously guarding some errors behind dev mode being enabled, meaning that turning on dev mode could break an app that otherwise works. IMHO, dev mode should add information by showing users additional context or inforamtion, but should not introduce large breaking changes into the app.
By allowing the client error console to receive messages via event, we can now have
bindAll()
report binding issues without throwing or breaking the app.This refactor also improves the code organization and opens us up to future improvements in a few ways:
ShinyClientMessage
in the future to add, for example, informational messages differentiated by atype
prop.shiny:client-message
event.Note that we do still throw an error when we detect more than one of the same input IDs or output IDs (i.e.
"debug"
is used for two+ inputs or is used for two+ outputs). In theory, these apps could still work but would be much harder to reason about. More importantly, by still throwing in these cases, this PR only changes behavior in the narrow case of the shared input/output ID.Example
The following app currently works as expected in "production" but breaks when devmode is enabled. With this PR, the app works in both modes and a message is shown either in the console or in the client error console when devmode is enabled.
The problem can be seen in this shinylive.io app (as of 2024-07-15).