fix: lazy-require wordnet so the client bundle stops hanging the editor#92
Conversation
ep_define's frontend CI has timed out (6h, cancelled) on every run since
the plugin started actually being installed in tests (Apr 2026), and the
pad editor never loaded in CI with ep_define present — `ace_outer` was
never created, no JS error was thrown, every spec (including core specs)
timed out waiting for the editor.
Root cause: `handleMessage.js` did `const wordnet = require('wordnet')`
at module top level. Etherpad's client bundler pulls plugin hook modules
into the browser bundle; evaluating wordnet's (server-only) module body
in the browser silently hangs the editor bootstrap. Bisected in CI: the
hook with the top-level require hangs the editor; a no-op handler (no
require) loads fine; moving the require lazily inside the hook with the
full plugin restored loads fine.
- Require `wordnet` lazily inside `ensureInit()` so its body only runs
server-side, on an actual define request.
- Stop returning `[null]` for non-define messages: that told core to
DROP every message (typing, cursor moves, …). Return nothing instead
so only the plugin's own define messages are intercepted.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
PR Summary by QodoFix client bundle hang by lazy-loading wordnet in handleMessage hook Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1. Rejected initPromise never resets
|
context.client.json.send() was the socket.io v2 API and no longer exists, so the define reply never reached the client and the gritter notification never appeared (define.spec.ts:13). Emit over context.socket and use the server-resolved sessionInfo author/pad instead of client-supplied ids.
Symptom
ep_define's frontend CI (
Node.js Package→frontend / test-frontend) has timed out at the 6-hour job limit and been cancelled on every run for months — including unrelated Dependabot PRs (#89). With ep_define installed, the pad editor never loads in CI: theace_outeriframe is never created, no JS error is thrown, and every spec — including core specs likea11y_dialogs— times out inbeforeEachwaiting for the editor.It does not reproduce locally (the editor loads fine), which is why it went unfixed: the failure only manifests in the CI build of the client bundle.
Root cause
handleMessage.jsrequired wordnet at module top level:Etherpad's client bundler pulls plugin hook modules into the browser bundle. Evaluating wordnet's server-only module body (it reads the WordNet DB off disk) in the browser silently hangs the editor bootstrap before
ace_outeris created — no exception, just a stuck "Loading…".Bisected directly in CI with an instrumented pad-load probe:
handleMessagehook (top-levelrequire('wordnet'))handleMessage(no require)Fix
wordnetlazily insideensureInit(), so its module body only ever runs server-side, on an actual define request — never during client bundle evaluation.[null]for non-define messages. That told core to drop every message (typing, cursor moves, …); it now returns nothing so only the plugin's own define messages are intercepted.Companion to #90 (the pnpm-pin CI fix), which was necessary but not sufficient — this is the actual editor-load blocker.
🤖 Generated with Claude Code