Skip to content

fix(engine): support Node 10 query parsing#5528

Open
tianrking wants to merge 1 commit into
socketio:mainfrom
tianrking:agent/node10-query-compat
Open

fix(engine): support Node 10 query parsing#5528
tianrking wants to merge 1 commit into
socketio:mainfrom
tianrking:agent/node10-query-compat

Conversation

@tianrking

Copy link
Copy Markdown

Summary

Fixes #5527.

Engine.IO advertises support for Node.js 10.2+, but both the standard HTTP server and the uWebSockets server parsed query strings with Object.fromEntries(), which was only added in Node.js 12. A polling handshake therefore threw before validation on supported Node 10 deployments.

Replace those calls with a shared URLSearchParams parser that uses Object.defineProperty. It preserves the previous last-value-wins behavior for duplicate keys and keeps __proto__ as an ordinary own property rather than mutating the query object's prototype.

Tests

  • Added a regression test that removes Object.fromEntries and verifies a polling handshake still succeeds.
  • npm run compile --workspace=engine.io
  • npx mocha --bail --exit test/server.js --grep 'without Object.fromEntries'
  • npx prettier --check lib/server.ts lib/userver.ts test/server.js
  • npx mocha --bail --exit reached 90 passing tests (including the new regression and existing __proto__ coverage); it then hit an existing xhr timeout after npm ci --ignore-scripts left the optional HTTP/3 native module unavailable on Windows.

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.

Using the function Object.fromEntries in a wrong node version

1 participant