Fix Server Reference being double registered #61244
Merged
+49
−9
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.
When we apply
createActionProxy
twice to the same value, it currently errors because we can't override the ID of it.This PR makes sure that 1) when the value already have an ID defined, we skip setting it again; 2) all the action IDs are being tracked even for duplicated ones.
Note that it's technically impossible to "detect" the duplication here (via static analyzation) and only set it once. For example:
So, the compiler will always wrap
createActionProxy
for every exported value and assume they're different Server Actions (hence different IDs). With this fix, if we find that it's already defined before, we just return the defined reference as they're strictly identical so the ID does't matter.Closes #54655, closes #61183.
Closes NEXT-2264