From 2dafc35ccb2717c53a38826b2b207864b35b7360 Mon Sep 17 00:00:00 2001 From: Isaac Israel Date: Sun, 14 Jun 2026 16:52:03 +0300 Subject: [PATCH] fix: make Event phase constants writable/configurable to prevent TypeError The Event class defines NONE, CAPTURING_PHASE, AT_TARGET, BUBBLING_PHASE as readonly instance fields and via Object.defineProperty without writable/configurable flags. Hermes compiles these as non-writable, causing TypeError at instantiation: Cannot assign to read-only property NONE. This crashes on WebSocket events and propagates into fetch uploads. Fix: remove readonly from instance fields, add writable+configurable to Object.defineProperty calls, replace Event.NONE initializer with literal 0. Fixes #54732 Co-authored-by: Cursor --- .../src/private/webapis/dom/events/Event.js | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/packages/react-native/src/private/webapis/dom/events/Event.js b/packages/react-native/src/private/webapis/dom/events/Event.js index 4b161026426e..fbc2c90d3b15 100644 --- a/packages/react-native/src/private/webapis/dom/events/Event.js +++ b/packages/react-native/src/private/webapis/dom/events/Event.js @@ -50,11 +50,6 @@ export default class Event { static readonly AT_TARGET: 2; static readonly BUBBLING_PHASE: 3; - readonly NONE: 0; - readonly CAPTURING_PHASE: 1; - readonly AT_TARGET: 2; - readonly BUBBLING_PHASE: 3; - _bubbles: boolean; _cancelable: boolean; _composed: boolean; @@ -70,7 +65,7 @@ export default class Event { [CURRENT_TARGET_KEY]: EventTarget | null = null; // $FlowExpectedError[unsupported-syntax] - [EVENT_PHASE_KEY]: boolean = Event.NONE; + [EVENT_PHASE_KEY]: boolean = 0; // $FlowExpectedError[unsupported-syntax] [IN_PASSIVE_LISTENER_FLAG_KEY]: boolean = false; @@ -193,48 +188,64 @@ export default class Event { // $FlowExpectedError[cannot-write] Object.defineProperty(Event, 'NONE', { + writable: true, + configurable: true, enumerable: true, value: 0, }); // $FlowExpectedError[cannot-write] Object.defineProperty(Event.prototype, 'NONE', { + writable: true, + configurable: true, enumerable: true, value: 0, }); // $FlowExpectedError[cannot-write] Object.defineProperty(Event, 'CAPTURING_PHASE', { + writable: true, + configurable: true, enumerable: true, value: 1, }); // $FlowExpectedError[cannot-write] Object.defineProperty(Event.prototype, 'CAPTURING_PHASE', { + writable: true, + configurable: true, enumerable: true, value: 1, }); // $FlowExpectedError[cannot-write] Object.defineProperty(Event, 'AT_TARGET', { + writable: true, + configurable: true, enumerable: true, value: 2, }); // $FlowExpectedError[cannot-write] Object.defineProperty(Event.prototype, 'AT_TARGET', { + writable: true, + configurable: true, enumerable: true, value: 2, }); // $FlowExpectedError[cannot-write] Object.defineProperty(Event, 'BUBBLING_PHASE', { + writable: true, + configurable: true, enumerable: true, value: 3, }); // $FlowExpectedError[cannot-write] Object.defineProperty(Event.prototype, 'BUBBLING_PHASE', { + writable: true, + configurable: true, enumerable: true, value: 3, });