https://sonarly.com/issue/42491?type=bug
Opening Companies right after creating a new Company field can throw a front-end invariant and break record update handling on that page. The failure is triggered by SSE event ordering, not by a backend outage.
Fix: Implemented the frontend race-condition fix in the SSE pipeline by applying metadata events before object-record optimistic updates in both SSE processing branches (`next` callback and `message` callback). This ensures local metadata is updated before `triggerOptimisticEffectFromSseEvents` can process record updates containing newly-created fields.
Concretely in `useTriggerEventStreamCreation`:
- Moved `dispatchMetadataEventsFromSseToBrowserEvents(metadataEvents)` ahead of optimistic/object-record dispatch in both event handlers.
- Kept existing object-record event dispatch behavior intact after metadata application.
I also checked recent history for existing fixes before editing and found a related prior candidate in all-history (`bab771b718`), but the current branch still contained the vulnerable ordering and unfiltered error callback path, so I applied the fix here.
Authored by Sonarly by autonomous analysis (run 48523).