-
Notifications
You must be signed in to change notification settings - Fork 35
Description
👟 Reproduction steps
I am experiencing a critical crash when using the Realtime API in a React Native CLI project. The app crashes with a TypeError: undefined is not a function whenever a WebSocket message is received. This appears to be an internal failure within the SDK's onMessage handler.
Error Stack Trace:
TypeError: undefined is not a function
at onMessage (sdk.js:225:72)
at anonymous (appwrite.ts:35:47)
at invoke (EventTarget.js:379:22)
at dispatchEvent (EventTarget.js:207:13)
System Information:
Environment: React Native CLI (Pure, No Expo)
Platform: iOS (Simulator and Physical Device)
Node Version: v25.4.0
NPM Version: 11.10.0
SDK Version: react-native-appwrite (Latest)
Architecture: New Architecture / Hermes
Steps to Reproduce:
-
Initialize Appwrite Client with setEndpoint, setProject, and setPlatform.
-
Subscribe to a collection channel via client.subscribe().
-
Trigger a database event (create/update a document).
-
The app crashes as soon as the WebSocket message arrives.
Fixes Already Attempted:
-
Added react-native-url-polyfill/auto at the absolute top of the entry file.
-
Reinstalled node_modules and cleared Metro cache (--reset-cache).
-
Verified iOS Bundle ID matches setPlatform.
-
Implemented stubs for expo-file-system to resolve dependency resolution issues in a CLI-only environment.
Supporting Files:
Reproducible Repository: https://github.com/DevHussein/SimpleTodoApp.git
Screenshot of Debugger:
Additional Context:
It seems that the SDK's onMessage handler is attempting to call a method on an object that remains undefined despite polyfilling. Given the Node v25 environment and CLI setup, there may be a conflict in how the global scope is being accessed or how the sdk.js logic expects the environment to behave.
👍 Expected behavior
The Realtime WebSocket connection should remain stable upon receiving a message. Specifically:
-
The SDK's onMessage handler should successfully parse the incoming payload.
-
The internal channels map/list within the SDK should be populated and accessible.
-
The subscribe callback function in my application code should be triggered with the event data.
👎 Actual Behavior
Despite following the official documentation and implementing the react-native-url-polyfill, the application crashes immediately upon receiving any WebSocket event from the Appwrite server.
-
Initialization: The WebSocket connection is successfully established (Status 101).
-
The Crash: As soon as an event is broadcast (e.g., a document update), the SDK's internal onMessage listener attempts to process the packet.
-
The Failure: The process terminates with TypeError: undefined is not a function. The stack trace points to sdk.js at a line involving the iteration of subscription channels.
-
Side Effects: This crash kills the JavaScript thread, causing the UI to freeze and requiring a full application restart. The error persists even when manually forcing URLSearchParams and self into the global object.
🎲 Appwrite version
Version 0.10.x
💻 Operating system
MacOS
🧱 Your Environment
No response
👀 Have you spent some time to check if this issue has been raised before?
- I checked and didn't find similar issue
🏢 Have you read the Code of Conduct?
- I have read the Code of Conduct