Skip to content

update dependencies to express 5, socket.io 4, node-cache 5 and fix breaking changes - #23

Merged
rongxin-liu merged 2 commits into
mainfrom
chore/update-dependencies
Sep 5, 2026
Merged

rongxin-liu merged 2 commits into
mainfrom
chore/update-dependencies

Conversation

@rongxin-liu

Copy link
Copy Markdown
Collaborator

Summary

Brings all dependencies to their latest versions (Express 5, Socket.IO 4, node-cache 5, mysql 2.18) and fixes the three breaking changes that came with them. Without the fixes, the upgraded app crashes on startup, and even if it started, no browser could connect. Also refreshes package-lock.json, which was still pinning the old versions, and bumps actions/checkout to v7.

What was broken by the upgrade

Change Effect before fix Fix
Express 4 → 5: bare app.get('*') is invalid in path-to-regexp v8 Server threw PathError: Missing parameter name and exited Route is now /{*splat}
Socket.IO 2 → 4: socket.join(room, cb) no longer takes a callback Silent failure: the callback never fired, so a board was never created or loaded from the DB join() is called synchronously, then the post-join logic runs directly
Vendored public/js/socket.io.js was the v2.1.1 client v4 server rejects it: {"code":5,"message":"Unsupported protocol version"} Replaced with the v4.8.3 client bundle from socket.io/client-dist

app.js also honors PORT if set (default is still 8080). No change for production, where nginx/Passenger in cs50/server run Node 24, which satisfies Express 5.

Test plan

Verified end-to-end against a MySQL 8.0 container loaded with db_initialize.mysql, with three simulated clients on the v4 protocol:

  • First join creates the board (joined on insert); later joins get boardState.
  • startDraw acks idx 0 then 1 (transaction + MAX(idx) work); updateDraw, endDraw, undo, pan are relayed to the room; undo deletes the row.
  • A late joiner receives both persisted paths.
  • A root-page client (no board in the URL) connects without crashing the server.
  • No errors in the server log. npm audit: 0 vulnerabilities.

Worth a quick manual check in a browser on two tabs of the same board before merge; the deploy workflow ships main straight to Elastic Beanstalk.

Not changed

  • node-cache is still listed but unused in app.js (only referenced in commented-out code). Left in place; could be dropped in a follow-up.

…reaking changes

Bump express ^4.16 -> ^5.2.1, socket.io ^2.1 -> ^4.8.3, node-cache ^4.2 -> ^5.1.2,
mysql ^2.16 -> ^2.18.1 and regenerate package-lock.json (0 vulnerabilities).

Adapt app.js and the vendored browser client to the major-version changes:

- Express 5 rejects the bare '*' route (path-to-regexp v8 requires named
  wildcards), which crashed the server on startup. Use '/{*splat}'.
- Socket.IO 3+ dropped the callback argument of socket.join(). The post-join
  logic (board lookup/insert, boardState emit) would never have run. Call
  join() synchronously and run that logic directly.
- Replace public/js/socket.io.js (v2.1.1) with the v4.8.3 client bundle. A
  v4 server rejects v2 clients with "Unsupported protocol version".
- Honor PORT env var (default remains 8080).

Verified end-to-end against MySQL 8.0: join/insert, boardState, startDraw
ack + transaction, updateDraw/endDraw/undo/pan relays, late-joiner state.
@rongxin-liu rongxin-liu self-assigned this Sep 5, 2026
@rongxin-liu
rongxin-liu merged commit 42422e6 into main Sep 5, 2026
1 check passed
@rongxin-liu
rongxin-liu deleted the chore/update-dependencies branch September 5, 2026 03:19
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