Skip to content

fix: handle null-prototype objects in typeName helper#36343

Open
srpatcha wants to merge 4 commits intofacebook:mainfrom
srpatcha:chore/add-gitattributes
Open

fix: handle null-prototype objects in typeName helper#36343
srpatcha wants to merge 4 commits intofacebook:mainfrom
srpatcha:chore/add-gitattributes

Conversation

@srpatcha
Copy link
Copy Markdown

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

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>
@meta-cla meta-cla Bot added the CLA Signed label Apr 25, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant