Skip to content

Commit 5516979

Browse files
refactor: serve "sse" from the middleware's own transport
The adapter this branch added, `lib/servers/EventSourceServer.js`, existed to dress the middleware's hot endpoint up as the transport shape this server was written against. There is no such shape any more — the middleware owns both ends of both transports — so naming `sse` is now just choosing one of its transports, and the adapter and its special case in `normalizeOptions` are gone with it. `client.webSocketTransport: "sse"` and `webSocketServer: "sse"` keep working and keep picking each other, which is what the option values are for. The published `client/clients/EventSourceClient.js` path is generated alongside its WebSocket neighbour, so a transport named by module still resolves. One thing this caught: `"sse"` was being read as an implementation of this server's own, since the test for that was "not `ws`" — which sent it looking for a class to construct and failed before a page could connect. Both of the middleware's transports are named now, and a smoke run over each confirms the endpoint answers: `426` to a plain GET on the WebSocket one, an event stream on the other. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA
1 parent 931ef71 commit 5516979

3 files changed

Lines changed: 8 additions & 12 deletions

File tree

‎client-src/clients/EventSourceClient.js‎

Lines changed: 0 additions & 9 deletions
This file was deleted.

‎lib/Server.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2424,8 +2424,12 @@ class Server {
24242424
const serverOptions =
24252425
/** @type {NonNullable<WebSocketServerConfiguration["options"]>} */
24262426
(webSocketServer.options) || {};
2427+
// `"ws"` and `"sse"` are the middleware's own transports. Anything else
2428+
// is an implementation of this server's own — as is either of those given
2429+
// a port or a server to listen on itself, which the middleware does not
2430+
// offer.
24272431
const isOwnSocket =
2428-
webSocketServer.type !== "ws" ||
2432+
(webSocketServer.type !== "ws" && webSocketServer.type !== "sse") ||
24292433
typeof serverOptions.port !== "undefined" ||
24302434
typeof serverOptions.server !== "undefined";
24312435

‎scripts/build-client.mjs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ const SHIMS = {
2929
"overlay.js": "webpack-dev-middleware/client/overlay",
3030
// The progress indicator, named `indicator` there.
3131
"progress.js": "webpack-dev-middleware/client/indicator",
32-
// What `client.webSocketTransport: "ws"` used to resolve to, and what a
33-
// transport of someone else's extends.
32+
// What `client.webSocketTransport` resolves to for each built-in transport,
33+
// and what a transport of someone else's extends.
3434
"clients/WebSocketClient.js": "webpack-dev-middleware/client/ws",
35+
"clients/EventSourceClient.js": "webpack-dev-middleware/client/sse",
3536
};
3637

3738
/**

0 commit comments

Comments
 (0)