Skip to content

Commit 6e1ea31

Browse files
committed
fix(client): the UNIX domain socket path compatibilities to nodejs before v22
1 parent 101859d commit 6e1ea31

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changes
22

3+
## v0.2.7
4+
5+
- fix(client): the UNIX domain socket path should work as expected.
6+
7+
The UDS path was mistakenly ignored when `forceNewConnection` is set to
8+
`true` on HTTP connections.
9+
310
## v0.2.6
411

512
- fix(client): the UNIX domain socket path should work as expected.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@litert/websocket",
3-
"version": "0.2.6",
3+
"version": "0.2.7",
44
"description": "The websocket protocol library for LiteRT.",
55
"main": "lib/index.js",
66
"scripts": {

src/lib/Client.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,18 @@ export function createClient(opts: IWsConnectOptions): D.IClient {
346346

347347
opts.agent = undefined;
348348

349-
opts.createConnection = (opts, onCreated) => {
350-
351-
const socketOpts: NodeNet.NetConnectOpts = {
349+
opts.createConnection = (connArgs, onCreated) => {
352350

353-
...opts,
354-
port: Number(opts.port ?? 80),
355-
host: opts.hostname ?? opts.host ?? 'localhost',
351+
const socketOpts: NodeNet.NetConnectOpts = opts.socketPath ? {
352+
'port': undefined,
353+
'host': undefined,
354+
'timeout': opts.connectTimeout ?? D.DEFAULT_CONNECT_TIMEOUT,
355+
'path': opts.socketPath,
356+
} : {
357+
'timeout': opts.connectTimeout ?? D.DEFAULT_CONNECT_TIMEOUT,
358+
'port': Number(connArgs.port ?? 80),
359+
'host': connArgs.hostname ?? connArgs.host ?? 'localhost',
360+
'path': undefined,
356361
};
357362

358363
const socket = NodeNet.connect(socketOpts);

0 commit comments

Comments
 (0)