ref(browser): Extract browser-specific normalize code into registerable util#21172
ref(browser): Extract browser-specific normalize code into registerable util#21172mydea wants to merge 6 commits into
normalize code into registerable util#21172Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3ed69bb. Configure here.
| return () => { | ||
| baseUnregister(); | ||
| unregister = undefined; | ||
| }; |
There was a problem hiding this comment.
Idempotent unregister breaks re-registration
Medium Severity
When registerDomEventNormalizer() runs while a registration already exists, it returns the raw addNormalizeUnpacker teardown instead of the wrapper that clears module state. Calling that teardown removes the unpacker but leaves the module unregister reference set, so later calls hit the idempotent branch and never call addNormalizeUnpacker again—DOM Event normalization stays off until the module reloads.
Reviewed by Cursor Bugbot for commit 3ed69bb. Configure here.
size-limit report 📦
|


Today, we have some browser-specific code in
corethat runs for all runtimes. Mainly this is around (browser)Event, which can havetargetandcurrentTargetdefined which are HTML elements. We have some code in place handling this in a custom way.This PR moves this code into
browser-utilsand changes it so this only runs in browser environments. There are two callsites:extractExceptionKeysForMessage- this is easy because we can just use the browser-utils implementation in the browser package, and use an implementation without Event support in core.normalize- this is harder because this is called from other core code, mainlyprepareEvent.To solve 2, this PR adds a
addNormalizeUnpackermethod that can be called to register a custom normalize unpacking function. So in core, nothing runs, while in browser this is called to register an additional unpacker for events.