Fix: Prevent uncatchable capability error from DefineFastFlag in client scripts #11
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 I tried using React-Roblox in a LocalScript, my app immediately crashed with this error:
The crash happens in
RobloxComponentProps.luawhen it tries to set upFFlagReactFixBindingMemoryLeak.How I Found the Issue
At first, I thought it was my code. I tried:
Folderto aScreenGuifor the root containerStrictModewrapperNothing worked. The app kept crashing before anything would render, so I dug into the library source.
What's Actually Wrong
Turns out
game:DefineFastFlag()needs a special permission calledRobloxScriptcapability. Only Roblox's internal server scripts have this - regular LocalScripts don't.The library tries to handle errors with
xpcall:But here's the catch: capability errors in Roblox can't be caught. Not by
pcall, not byxpcall. They just blow right past error handlers and kill your script.The Fix
Instead of trying to catch an uncatchable error, just check if we're in the right context first:
Why This Works Better
What I Tested
I verified this works with:
createRootand aScreenGuiNo errors, everything renders properly now.
Who This Affects
Anyone using React-Roblox in a client context - whether you're using roblox-ts or writing Luau directly.
What Changed:
modules/react-roblox/src/client/RobloxComponentProps.luaChange Type: