feat: convert websockets to server-side events#1587
Merged
tyler-dane merged 9 commits intomainfrom Mar 30, 2026
Merged
Conversation
e2d02f1 to
e682637
Compare
…eal-time updates - Updated documentation and codebase to replace WebSocket references with SSE, enhancing the real-time communication mechanism. - Modified AGENTS.md, README, and various architecture documents to reflect the shift to SSE for Google Calendar sync and event notifications. - Introduced a new feature document for Google Sync and SSE, detailing the architecture and event flow. - Removed obsolete WebSocket code and dependencies from the backend, ensuring a cleaner and more maintainable codebase. - Updated tests and hooks to utilize SSE, ensuring consistent behavior across the application.
- Updated "@adobe/css-tools" to version 4.4.4. - Removed obsolete "socket.io" and "socket.io-client" dependencies. - Updated "@emnapi/core" and "@emnapi/runtime" to version 1.9.1. - Updated "@napi-rs/wasm-runtime" to version 1.1.2 with peer dependencies. - Bumped "@opentelemetry/api" to version 1.9.1 and "@opentelemetry/core" to version 2.6.1. - Updated "@posthog/core" to version 1.24.3 and "@posthog/types" to version 1.364.1. - Updated "@sinclair/typebox" to version 0.34.49 and "@tanstack/react-store" to version 0.9.3. - Updated "@tanstack/store" to version 0.9.3.
- Introduced an alias for the SSE module in the webpack configuration, enhancing module resolution and improving code organization.
- Added a condition in the loadAuthenticated function to return an unauthenticated state when NODE_ENV is set to "test", preventing session checks from blocking navigation during Playwright e2e tests.
- Replaced direct EventSource event listeners with an EventEmitter2 instance for improved event management. - Updated hooks to utilize the new sseEmitter for handling SSE events, enhancing modularity and maintainability. - Refactored tests to accommodate the changes in event handling, ensuring consistent behavior across the application.
…t coverage - Changed the USER_METADATA publishing method in the SSE server to use a response object, improving the handling of server-sent events. - Added a test to ensure that USER_METADATA is not replayed to existing tabs when a new tab opens, enhancing the reliability of the SSE implementation.
- Moved the initialization of eventName and dataLine variables outside the loop in the BaseDriver class, improving code clarity and reducing redundancy. - Updated the test file for SSE server to remove redundant comments, enhancing readability while maintaining the test environment setup.
- Added a check to send a 500 status response if an error occurs while opening the SSE stream and headers have not been sent, improving error handling in the EventsController. - Removed obsolete socket alias from jest configuration, streamlining module resolution for the web project.
- Updated the connection handling logic in the SSE server to utilize a dedicated method for removing dead connections, enhancing code clarity and maintainability. - Refactored the subscription and error handling processes to ensure proper cleanup of connections, improving overall reliability of the SSE implementation.
15238f2 to
cc0b5ab
Compare
tyler-dane
added a commit
to Muhammad-Nur-Alamsyah-Anwar/compass
that referenced
this pull request
Mar 30, 2026
* refactor: transition from WebSocket to Server-Sent Events (SSE) for real-time updates - Updated documentation and codebase to replace WebSocket references with SSE, enhancing the real-time communication mechanism. - Modified AGENTS.md, README, and various architecture documents to reflect the shift to SSE for Google Calendar sync and event notifications. - Introduced a new feature document for Google Sync and SSE, detailing the architecture and event flow. - Removed obsolete WebSocket code and dependencies from the backend, ensuring a cleaner and more maintainable codebase. - Updated tests and hooks to utilize SSE, ensuring consistent behavior across the application. * chore(deps): update dependencies in yarn.lock - Updated "@adobe/css-tools" to version 4.4.4. - Removed obsolete "socket.io" and "socket.io-client" dependencies. - Updated "@emnapi/core" and "@emnapi/runtime" to version 1.9.1. - Updated "@napi-rs/wasm-runtime" to version 1.1.2 with peer dependencies. - Bumped "@opentelemetry/api" to version 1.9.1 and "@opentelemetry/core" to version 2.6.1. - Updated "@posthog/core" to version 1.24.3 and "@posthog/types" to version 1.364.1. - Updated "@sinclair/typebox" to version 0.34.49 and "@tanstack/react-store" to version 0.9.3. - Updated "@tanstack/store" to version 0.9.3. * feat(webpack): add alias for Server-Sent Events (SSE) module - Introduced an alias for the SSE module in the webpack configuration, enhancing module resolution and improving code organization. * fix(loaders): handle SuperTokens session checks in test environment - Added a condition in the loadAuthenticated function to return an unauthenticated state when NODE_ENV is set to "test", preventing session checks from blocking navigation during Playwright e2e tests. * refactor(sse): transition to EventEmitter for SSE event handling - Replaced direct EventSource event listeners with an EventEmitter2 instance for improved event management. - Updated hooks to utilize the new sseEmitter for handling SSE events, enhancing modularity and maintainability. - Refactored tests to accommodate the changes in event handling, ensuring consistent behavior across the application. * refactor(sse): update USER_METADATA publishing method and enhance test coverage - Changed the USER_METADATA publishing method in the SSE server to use a response object, improving the handling of server-sent events. - Added a test to ensure that USER_METADATA is not replayed to existing tabs when a new tab opens, enhancing the reliability of the SSE implementation. * refactor(base.driver): streamline event handling in BaseDriver class - Moved the initialization of eventName and dataLine variables outside the loop in the BaseDriver class, improving code clarity and reducing redundancy. - Updated the test file for SSE server to remove redundant comments, enhancing readability while maintaining the test environment setup. * fix(events): ensure proper response handling for SSE stream errors - Added a check to send a 500 status response if an error occurs while opening the SSE stream and headers have not been sent, improving error handling in the EventsController. - Removed obsolete socket alias from jest configuration, streamlining module resolution for the web project. * refactor(sse): improve connection management in SSE server - Updated the connection handling logic in the SSE server to utilize a dedicated method for removing dead connections, enhancing code clarity and maintainability. - Refactored the subscription and error handling processes to ensure proper cleanup of connections, improving overall reliability of the SSE implementation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Note
Medium Risk
Touches realtime delivery and Google-sync error/notification paths; misconfigurations in SSE streaming/heartbeats or listener wiring could cause stale UI updates or missed import/revocation signals.
Overview
Switches the app’s realtime notification mechanism from
socket.ioWebSockets to Server-Sent Events (SSE) via an authenticatedGET /api/events/streamendpoint, with a new backendsseServerhandling per-user connections, heartbeats, and event fanout.Migrates Google sync/import and revocation notifications (
EVENT_CHANGED,SOMEDAY_EVENT_CHANGED,IMPORT_GCAL_*,USER_METADATA,GOOGLE_REVOKED) to sharedcoreSSE constants/types, rewires backend emitters/error handling/sync processors to publish over SSE, and updates the web client to manage anEventSourcestream (SSEProvider+ hooks) instead of socket listeners.Removes WebSocket infrastructure and dependencies across backend/web, updates Jest module mapping and tests accordingly, and adds documentation for the new Google sync + SSE flow and deployment considerations for long-lived
text/event-streamconnections.Written by Cursor Bugbot for commit cc0b5ab. This will update automatically on new commits. Configure here.