Conversation
…nsure socket disconnection when app is in background
…events in socket context
| } | ||
| } | ||
|
|
||
| // Start periodic buffer flushing |
There was a problem hiding this comment.
Bug: Unstoppable intervals leak system resources.
The startBufferFlushing method creates an interval with setInterval but never stores the interval ID or provides a way to clear it. This creates a memory leak because the interval will continue running even if the service is destroyed or the application shuts down. The interval should be stored and cleared in a cleanup method.
| setMessages((prev) => [...prev, data.message]); | ||
| }); | ||
| _socket.on("message:delivered", (data) => { | ||
| console.log("Received message:delivered", data); |
There was a problem hiding this comment.
Bug: Chat Messages Lack Full Context
The chat:receive event handler extracts data.message and adds it to the messages array, but the backend sends the full message object with properties like id, timestamp, senderId, etc. Extracting only data.message loses critical metadata. The frontend should store the complete message object to display sender information, timestamps, and message IDs for proper chat functionality.
| console.log("Received notification:", data); | ||
| pub.publish("NOTIFICATION_MESSAGES", JSON.stringify(data)); | ||
| }); | ||
| }; |
There was a problem hiding this comment.
Bug: Null Publisher Breaks Notifications
The notification socket handler calls pub.publish() without checking if pub is null. When VALKEY_HOST is not configured, pub is null (as set in socket.js), causing a runtime error when notifications are sent. The handler needs to verify pub exists before publishing.
| required: true, | ||
| default: Date.now, | ||
| expires: 600 // 10 minutes in seconds | ||
| }, |
There was a problem hiding this comment.
Bug: Broken Expiration: Documents Vanish Instantly
The expiresAt field has both default: Date.now and expires: 600. The default sets the expiration time to the current timestamp instead of 10 minutes in the future. Documents will expire immediately upon creation. The default should be Date.now() + 600000 or removed entirely if set programmatically.
Note
Refactors backend into a new src app with email OTP auth, sockets/Kafka, Cloudinary, and image/static APIs, migrates data model from phone to email, and updates the frontend (auth, posts, chat, images) to the new endpoints and real-time stack.
src/(app.js, robustindex.jsfor Azure/iisnode) withweb.configand static serving under/public./auth/*) with JWT,Otpmodel, token verification, and profile update.phonetoemail(User,Post); addMessagemodel with indexes/TTL.postRoutes,userRoutes(email-based + JWT profile),messageRoutes(CRUD/status/stats),imageRoutes(serve/list images).sockets/*) with optional Redis (Valkey) pub/sub; add Kafka config/producer/consumer andmessageServicefor persistence/batching.routes/postRoutes.js(phone-based).AuthContext), logout, token storage; update README and EAS env toEXPO_PUBLIC_BASE_URL.emailand new/apiendpoints; add base64 conversion for image upload; owner actions (edit/delete) and improved image loading placeholders.SocketContext,AppStateListener, wrap app with provider; rework Chat/Notifications to use Socket.io.menuscreen, sidebar slides from right; asset paths updated.imageServiceto load backend-hosted images with fallbacks.package.jsonpoints tosrc/index.js; add dependencies (socket.io-client, etc.); updateapp.jsonasset paths and EAS env vars.Written by Cursor Bugbot for commit 499d2a1. This will update automatically on new commits. Configure here.