Skip to content

Code maintenance/STC-834: Bump Hocuspocus client & server to v4.2.0 (lockstep)#23754

Open
akabiru wants to merge 2 commits into
devfrom
chore/hocuspocus-server-v4
Open

Code maintenance/STC-834: Bump Hocuspocus client & server to v4.2.0 (lockstep)#23754
akabiru wants to merge 2 commits into
devfrom
chore/hocuspocus-server-v4

Conversation

@akabiru

@akabiru akabiru commented Jun 15, 2026

Copy link
Copy Markdown
Member

Ticket

https://community.openproject.org/wp/STC-834

Server-side follow-up to the @hocuspocus/provider v4 client bump in #23570.

What are you trying to accomplish?

#23570 moves the frontend client @hocuspocus/provider to v4. The collaboration server in op-blocknote-hocuspocus was still on v3. The two talk over a versioned wire protocol and ship as independent artifacts — the server is the separately built openproject/hocuspocus image — so a one-major skew is tolerated, but the goal is to bring the server up to v4 as well so both halves run the current major.

This PR bumps @hocuspocus/server and @hocuspocus/extension-logger to v4 and applies the API changes the major introduces.

What v4 changes, and how it's applied here

v4 is a cross-runtime release that standardizes the server hook payloads on web-standard primitives and restructures a couple of hook shapes (v4.0.0 release notes, full diff). Three of those touch our OpenProjectApi extension:

  • Request headers are now a web-standard Headers object — upgrade guide §2 Request and Headers (Breaking). onAuthenticate previously read the request origin off a plain object (data.request.headers.origin). v4 exposes it as Headers, accessed with .get():

    // before (v3)
    const requestOrigin = data.request?.headers?.origin;
    // after (v4)
    const requestOrigin = data.requestHeaders?.get("origin") ?? undefined;

    This matters beyond a rename: against v4 the old plain-object access would silently return undefined, quietly weakening the origin check passed to decryptAndValidateToken.

  • The store hook's context is renamed contextlastContext — upgrade guide §3 onStoreDocument Payload (Breaking). onStoreDocument reads the resource URL, readonly flag, and token from the snapshot of the last connection context:

    // before (v3): data.context
    // after (v4):  data.lastContext
    const { resourceUrl, readonly } = data.lastContext;
  • Broadcasting to connected clients goes through Document#broadcastStateless. In v4 Document.connections is a Map<Connection, { clients }>, so the old connections.forEach(({ connection }) => connection.sendStateless(...)) no longer typechecks. broadcastStateless is the supported helper for this (CHANGELOG, client-initiated broadcastStateless #1103):

    // before (v3)
    data.document.connections.forEach(({ connection }) => connection.sendStateless("storeEvent"));
    // after (v4)
    data.document.broadcastStateless("storeEvent");

The rest of the extension is unchanged: onTokenSync, connection.close({ code, reason }), connectionConfig.readOnly, and the ad-hoc context writes all compile and behave the same under v4. @hocuspocus/common resolves to v4 transitively; closeEvents.ts already uses the v4-narrowed { code, reason } CloseEvent shape (upgrade guide §11 CloseEvent Shape), so no change was needed there.

References

A standing assertion of the client/server compatibility, plus a CI guard against future major drift, lands in the follow-up #23755.

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (n/a)
  • Tested major browsers (live smoke test in Chrome)

Comment thread .github/workflows/hocuspocus-version-skew.yml Fixed
@akabiru akabiru force-pushed the chore/hocuspocus-server-v4 branch from f2da4cd to e728048 Compare June 15, 2026 11:46
@github-actions

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./modules/my_page/spec/features/my/work_package_table_spec.rb[1:1:1]

@akabiru akabiru force-pushed the chore/hocuspocus-server-v4 branch from e728048 to b9f0dbc Compare June 15, 2026 12:06
@akabiru akabiru force-pushed the chore/hocuspocus-server-v4 branch from b9f0dbc to a2d05eb Compare June 15, 2026 12:43
@akabiru akabiru changed the base branch from dev to dependabot/npm_and_yarn/frontend/dev/hocuspocus/provider-4.0.0 June 15, 2026 12:44
@akabiru akabiru force-pushed the chore/hocuspocus-server-v4 branch from a2d05eb to 489b07a Compare June 15, 2026 12:46
@akabiru akabiru changed the title Chore: Upgrade op-blocknote-hocuspocus to Hocuspocus v4 and add version-skew guard Chore: Upgrade op-blocknote-hocuspocus to Hocuspocus v4 Jun 15, 2026
@akabiru akabiru self-assigned this Jun 15, 2026
@github-actions

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./modules/wikis/spec/features/admin/internal_provider_spec.rb[1:1]
  • rspec ./spec/features/projects/lists/filters_spec.rb[1:6:1]

@thykel

thykel commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

@akabiru Looks like upstream is already on 4.2.0, do we want to follow that? (It contains some important-looking fixes.)

@akabiru akabiru changed the title Chore: Upgrade op-blocknote-hocuspocus to Hocuspocus v4 Chore: Upgrade op-blocknote-hocuspocus @hocuspocus/provider from v3.4.4 → v4.0.0 Jun 15, 2026
@akabiru akabiru changed the title Chore: Upgrade op-blocknote-hocuspocus @hocuspocus/provider from v3.4.4 → v4.0.0 Chore: Upgrade @hocuspocus/server from v3.4.4 → v4.0.0 Jun 15, 2026
@akabiru akabiru changed the title Chore: Upgrade @hocuspocus/server from v3.4.4 → v4.0.0 Code maintenance/STC-834: Bump @hocuspocus/server from v3.4.4 → v4.0.0 Jun 15, 2026
@akabiru

akabiru commented Jun 15, 2026

Copy link
Copy Markdown
Member Author

@akabiru Looks like upstream is already on 4.2.0, do we want to follow that? (It contains some important-looking fixes.)

Yes, good catch @thykel 👍🏾

Base automatically changed from dependabot/npm_and_yarn/frontend/dev/hocuspocus/provider-4.0.0 to dev June 15, 2026 16:29
@akabiru akabiru changed the title Code maintenance/STC-834: Bump @hocuspocus/server from v3.4.4 → v4.0.0 Code maintenance/STC-834: Bump @hocuspocus/server from v3.4.4 → v4.2.0 Jun 15, 2026
@akabiru akabiru force-pushed the chore/hocuspocus-server-v4 branch from 489b07a to bb450fd Compare June 15, 2026 16:33
@akabiru akabiru changed the title Code maintenance/STC-834: Bump @hocuspocus/server from v3.4.4 → v4.2.0 Code maintenance/STC-834: Bump Hocuspocus client & server to v4.2.0 (lockstep) Jun 15, 2026
@akabiru akabiru marked this pull request as ready for review June 15, 2026 17:09
@akabiru akabiru requested review from a team and Copilot June 15, 2026 17:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Aligns OpenProject’s collaborative editing stack by bumping both the frontend @hocuspocus/provider and the op-blocknote-hocuspocus server-side packages to Hocuspocus v4.2.0, and adapting the server extension hook payload changes introduced in v4.

Changes:

  • Bump @hocuspocus/provider in the frontend to ^4.2.0 (with updated lockfile).
  • Bump @hocuspocus/server and @hocuspocus/extension-logger in op-blocknote-hocuspocus to ^4.2.0 (with updated lockfile).
  • Update OpenProjectApi extension to v4 hook payload shapes (requestHeaders, lastContext, broadcastStateless) and adjust unit tests accordingly.

Reviewed changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
frontend/package.json Bumps @hocuspocus/provider to v4.2.0.
frontend/package-lock.json Updates resolved v4.2.0 provider/common dependencies and lock metadata.
extensions/op-blocknote-hocuspocus/src/extensions/openProjectApi.ts Adapts server extension to Hocuspocus v4 hook payload API changes.
extensions/op-blocknote-hocuspocus/test/extensions/openProjectApi.test.ts Updates unit tests to reflect v4 hook payload changes.
extensions/op-blocknote-hocuspocus/package.json Bumps server-side Hocuspocus dependencies to v4.2.0.
extensions/op-blocknote-hocuspocus/package-lock.json Updates resolved v4.2.0 server/common/logger dependencies and transitive graph.
Files not reviewed (2)
  • extensions/op-blocknote-hocuspocus/package-lock.json: Generated file
  • frontend/package-lock.json: Generated file
Comments suppressed due to low confidence (1)

extensions/op-blocknote-hocuspocus/src/extensions/openProjectApi.ts:110

  • The warning message still refers to "context", but the hook payload was migrated to lastContext. This can be confusing when debugging stores (it will look like the old payload shape is still in use).
    const { resourceUrl, readonly } = data.lastContext;

    if (!resourceUrl) {
      console.warn("Missing parameters in context. Skipping store.");
      return;

akabiru added 2 commits June 15, 2026 20:16
Realigns the collaboration server with the v4 @hocuspocus/provider used on the
frontend. v4 moves hook payloads to web-standard Headers and renames the store
hook's context, so onAuthenticate reads the origin via requestHeaders and
onStoreDocument uses lastContext and Document#broadcastStateless.
Aligns the collaboration client with the server on the same v4 minor so the
two halves move in lockstep rather than only sharing a major. Provider v4.2.0
drops its ws dependency (the browser uses the native WebSocket), leaving ws as
dev-only tooling.
@akabiru akabiru force-pushed the chore/hocuspocus-server-v4 branch from 8ed13d1 to a12237e Compare June 15, 2026 17:16
@github-actions

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./modules/my_page/spec/features/my/work_package_table_spec.rb[1:1:1]

@akabiru akabiru added this to the 17.6.x milestone Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants