Skip to content

Upgrade karma to 6.4.4 to pull in engine.io 6.6.11 - #2

Open
cursor[bot] wants to merge 2 commits into
masterfrom
cursor-engineio-polling-fix-08e8
Open

cursor[bot] wants to merge 2 commits into
masterfrom
cursor-engineio-polling-fix-08e8

Conversation

@cursor

@cursor cursor Bot commented Nov 18, 2026

Copy link
Copy Markdown

What

package-lock.json locked engine.io 6.1.3 (through karma 6.3.16 → socket.io 4.4.1). Engine.IO versions from 4.1.0 up to, but not including, 6.6.7 have a bug in the protocol v4 polling transport. When a client sends a POST with Content-Type: application/octet-stream, the server calls onError("invalid content") and returns without ever ending the HTTP response (build/transports/polling.js, onDataRequest). Each such request leaves a connection and socket open on the server. The karma test server (tests/karma.config.js, tests/karma.config.dev.js, port 9876, default transports including polling, listening on all interfaces) exposes this endpoint. In the dev config the server keeps running because it uses autoWatch without singleRun.

Fix

  • Bump karma in devDependencies from ^6.3.16 to ^6.4.4, and let npm rewrite the lockfile. karma 6.4.4 depends on socket.io ^4.7.2. That resolves socket.io 4.8.4, which pulls in engine.io 6.6.11 (~6.6.0; the fix shipped in 6.6.7). In 6.6.11, the invalid-binary branch now does res.writeHead(400).end().
  • The lockfile only changes inside karma's socket.io/engine.io subtree, plus the deduped mime-types/mime-db, cookie, cors and ws they need. There is only one copy of engine.io in the tree.
  • Add tests/karma-polling.test.js and include it in npm test. The test starts karma's real server from tests/karma.config.dev.js with no browsers, opens an Engine.IO v4 polling session, and sends a binary POST. It fails if the server doesn't answer within 3 s. It loads only the karma-mocha and karma-sinon-expect plugins, so it doesn't need a PhantomJS binary.

Options considered

  • An overrides entry forcing engine.io >=6.6.7 would also work. But socket.io 4.4.1 declares engine.io ~6.1.0, so the override would run it against a version it doesn't support. This repo also doesn't use overrides today. Upgrading karma, the direct dependency, keeps everything inside declared ranges.

Tests

Test Before (engine.io 6.1.3) After (engine.io 6.6.11)
node tests/karma-polling.test.js FAIL: "binary polling POST was not answered … within 3000ms" PASS: answered with status 400
karma start tests/karma.config.js (PhantomJS, run with OPENSSL_CONF=/dev/null on this machine) 43/43 SUCCESS 43/43 SUCCESS
node tests/po2json.test.js both dumps correct both dumps correct

I also repeated the attack against the fix: 200 concurrent polling sessions, each sending a 64 KiB binary POST to karma's server from tests/karma.config.js. All 200 were answered.

Left to CI / notes for reviewers

  • I didn't run the full npm test. Its script already referenced tests/plural.test.js, which doesn't exist in the repo, so it fails at that step on master too.
  • .travis.yml targets Node 9. The existing lockfile already needed Node ≥ 10 (karma 6.3.16, engine.io 6.1.3). After this change the floor is Node ≥ 10.2.0 (engine.io 6.6.11), so the CI config was already out of date before this change.
Open in Web Open in Cursor 

socket.io 4.4.1 (pulled in by karma 6.3.16) pins engine.io ~6.1.0, whose
polling transport never ends the HTTP response for binary POSTs on
protocol v4, letting clients pile up open connections on the karma
server. karma 6.4.4 depends on socket.io ^4.7.2, which resolves
engine.io 6.6.11 (fixed in 6.6.7).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant