fix: handle null-prototype objects in typeName helper#36343
Open
srpatcha wants to merge 4 commits intofacebook:mainfrom
Open
fix: handle null-prototype objects in typeName helper#36343srpatcha wants to merge 4 commits intofacebook:mainfrom
srpatcha wants to merge 4 commits intofacebook:mainfrom
Conversation
typeName() accessed value.constructor.name without guarding against null-prototype objects (created via Object.create(null)), which have no constructor property. Added a guard with fallback to Object.prototype.toString.call() and a try-catch wrapper. Signed-off-by: Srikanth Patchava <spatchava@meta.com> Signed-off-by: Srikanth Patchava <srikanth.patchava@outlook.com>
Add throttled callback hook with: - Configurable delay with leading/trailing edge options - Cancel and flush API for pending invocations - Pending state tracking - Proper cleanup on unmount (timer cancellation) - Uses refs to always invoke latest callback without re-creating throttled fn - TypeScript-compatible JSDoc annotations Signed-off-by: Srikanth Patchava <spatchava@meta.com>
Add isSubscribed guard to handleStoreChange in subscribeToStore to prevent the callback from firing after the component has conceptually unmounted but before the passive effect cleanup runs. The cleanup now sets isSubscribed=false before calling unsubscribe, closing the timing window where handleStoreChange could operate on a stale fiber reference. Signed-off-by: Srikanth Patchava <spatchava@meta.com>
Test coverage includes: - Leading edge immediate invocation - Throttling within delay window - Leading-only and trailing-only modes - Cancel API prevents pending trailing invocations - Flush API triggers immediate invocation - Latest callback ref is used without re-creating throttled fn - Timer cleanup on unmount prevents stale invocations Signed-off-by: Srikanth Patchava <spatchava@meta.com>
This file contains hidden or 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
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.
Summary\n\nFixes crash in packages/shared/CheckStringCoercion.js:\n\n\ ypeName()\ accessed \�alue.constructor.name\ without guarding against null-prototype objects (created via \Object.create(null)), which have no .constructor\ property. This prevented helpful error messages from printing.\n\nAdded guard with fallback to \Object.prototype.toString.call()\ and try-catch wrapper.\n\nAlso adds .gitattributes for consistent line endings.\n\nSigned-off-by: Srikanth Patchava spatchava@meta.com