[WIKI-682] feat: hocuspocus v3 server migration#7880
[WIKI-682] feat: hocuspocus v3 server migration#7880sriramveeraghanta merged 2 commits intopreviewfrom
Conversation
WalkthroughUpgrades Hocuspocus packages to v3, updates server initialization to the new Hocuspocus constructor, adjusts Redis extension to use encodeMessage with publish, and changes shutdown to closeConnections without awaiting destroy. No public API exports changed. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client
participant Hocuspocus
participant Extensions
participant Redis
rect rgba(230,240,255,0.5)
note over Hocuspocus: Initialization (v3)
Client->>Hocuspocus: Connect
Hocuspocus->>Extensions: Load extensions
end
rect rgba(240,255,240,0.5)
note over Extensions,Redis: Redis broadcast (updated)
Extensions->>Extensions: encodeMessage(message.toUint8Array())
Extensions->>Redis: publish(encodedMessage)
end
rect rgba(255,245,230,0.5)
note over Hocuspocus: Shutdown (changed)
Client-->>Hocuspocus: Disconnect/Signal
Hocuspocus->>Hocuspocus: closeConnections()
note over Hocuspocus: Connections closed (server not destroyed here)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🧪 Early access (Sonnet 4.5): enabledWe are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience. Note:
Comment |
|
Linked to Plane Work Item(s) This comment was auto-generated by Plane |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/live/src/extensions/redis.ts (1)
23-28: Consider requesting public API for custom broadcasting.If
broadcastToDocumentis a common pattern in your codebase, consider opening a feature request with the Hocuspocus project to expose a public API for custom broadcast operations. This would eliminate the fragile dependency on private methods and provide a stable extension point.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (4)
apps/live/package.json(1 hunks)apps/live/src/extensions/redis.ts(1 hunks)apps/live/src/hocuspocus.ts(2 hunks)apps/live/src/server.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/live/src/server.ts (1)
packages/logger/src/config.ts (1)
logger(14-14)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build and lint web apps
- GitHub Check: Analyze (javascript)
🔇 Additional comments (5)
apps/live/src/hocuspocus.ts (2)
1-1: LGTM! Correct import for v3 migration.The import has been correctly updated from
ServertoHocuspocus, aligning with the v3 API separation whereHocuspocusis used for library/embedding patterns (as opposed to the standaloneServerclass for built-in server scenarios).Based on learnings.
39-45: LGTM! Correct instantiation pattern for v3.The migration correctly replaces
Server.configure({...})withnew Hocuspocus({...}), which is the primary breaking change in the v3 upgrade. The configuration object structure (name, hooks, extensions, debounce) remains compatible.Based on learnings.
apps/live/src/server.ts (1)
102-103: VerifycloseConnections()does not require awaiting
The migration replacedawait destroy()with a synchronous call tocloseConnections(). IfcloseConnections()returns a Promise (e.g., for flushing pending messages or notifying clients), not awaiting it can cause incomplete cleanup or race conditions before shutting down Redis and the HTTP server. Confirm via the library’s TypeScript definitions or documentation thatcloseConnections()is truly synchronous.apps/live/src/extensions/redis.ts (1)
23-28: Verify private Redis extension APIs and publish signature
• ConfirmpubKeyandencodeMessageremain available and stable in@hocuspocus/extension-redisv3.
• EnsureencodeMessage(message.toUint8Array())produces the correct wire format (including any metadata prefixes).
• Verifypublishaccepts a rawUint8Arraypayload rather than a structured object.
Manually inspect the installed v3 package (for example vianpm explore @hocuspocus/extension-redis -- cat src/index.ts) to confirm these APIs and signatures.apps/live/package.json (1)
24-27: Verify resolved @hocuspocus versions post-install. Runnpm install(ornpm ci), then confirm in your lockfile that@hocuspocus/server,@hocuspocus/extension-database,@hocuspocus/extension-logger, and@hocuspocus/extension-redisare resolved to v3.2.3 (or another tested 3.x release), and re-run the security advisory check to ensure no vulnerabilities.
* fix: hocuspocus v3 * fix: publishing messages across redis extension
Description
Upgrades hocuspocus to v3
Type of Change
Screenshots and Media (if applicable)
Test Scenarios
References
Summary by CodeRabbit
Chores
Refactor
Impact: Improves compatibility with the latest collaboration engine and streamlines connection handling for more reliable live sessions.