Upgrade hocuspocus v3, Elasticsearch client v9, and related dependencies#9
Upgrade hocuspocus v3, Elasticsearch client v9, and related dependencies#9
Conversation
Upgrade @hocuspocus/server, extension-logger, extension-database, provider, and transformer from v2.x to v3.4.4. Also bump yjs to 13.6.30 and y-prosemirror to 1.3.7.
In hocuspocus v3, Server.configure() was removed. Use the constructor directly.
Pull rumors-db from 032b83e to 71a0f36. Major changes include migration of schema files from .js to .ts, ES6 to ES9 migration, and new badges schema.
- Use named imports: import { Client, type ClientOptions } from '@elastic/elasticsearch'
- Remove 'type' parameter (document types removed in ES 9)
- Unwrap 'body' parameter in update/get calls
- Use 'document' instead of 'body' for index calls
- Remove '.body' wrapper from responses
- Add type parameters to get() calls for type safety
Migrate Hocuspocus/Configuration to Server/ServerConfiguration, remove deprecated broadcast/quiet options, fix server.listen() return type, and add provider.attach() required by v3 for shared websocketProvider.
- Migrate test ES client calls to v9 API (named imports, no type param, no body wrapper) - Use port 0 instead of hardcoded 1234 to avoid EADDRINUSE - Add test document cleanup to prevent test pollution
Coverage Report for CI Build 24178351899Coverage decreased (-14.9%) to 75.581%Details
Uncovered Changes
Coverage Regressions1 previously-covered line in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
There was a problem hiding this comment.
Code Review
This pull request upgrades the project to Elasticsearch v9 and Hocuspocus v3. The changes involve updating dependency versions in package.json files, refactoring Elasticsearch client interactions to use the updated API (e.g., removing the type parameter and flattening request structures), and migrating from the Hocuspocus class to the Server class. Review feedback suggests applying more consistent optional chaining in error handling logic within src/snapshot.ts to improve robustness.
There was a problem hiding this comment.
The update looks great! However, docker image build is somehow broken, so I cannot deploy it on staging. Would you take a look @nonumpa ?
https://github.com/cofacts/collab-server/actions/runs/24156795262/job/70497811406#step:6:294
Migration scripts use legacy ES v6 API and are run manually via ts-node, not as part of the Docker image. Excluding them from tsc fixes the build failure without needing to port dead migration code to the v9 client API.
|
Fixed and the build passed |
|
Note that there's also an yjs-upgrade in rumors-site. |
|
Probably Dockerfile is using a node js version that is too old. Upgrading to Node 24 should help |
@elastic/elasticsearch v9 depends on undici which requires the global File API (available since Node.js 20). The Docker image was still using Node 18, causing 'ReferenceError: File is not defined' at startup. Aligns Dockerfile with CI which already uses Node 24.
…fier-resolution --experimental-specifier-resolution=node was removed in Node 22+. Add .js extensions to all relative imports so ESM resolution works natively without the flag on Node 24.
|
Sorry about that! The Dockerfile was still on Node 18, which doesn't have the global Upgraded both stages to build: https://github.com/cofacts/collab-server/actions/runs/24178547334/job/70565538065 |



Summary
Changes
Hocuspocus v2 → v3
Server.configure({...})→new Server({...})websocketProviderwithattach()/detach()Elasticsearch v6 → v9
import { Client } from '@elastic/elasticsearch'bodywrapper — params go directlyindex():body→documentupdate():body: { doc, script }→doc, scriptdirectlyresult.body→resultdirectlybulk():body→operationsCI
elasticsearch-oss:6.3.2→elasticsearch:9.2.2