Skip to content

Commit ea4a5cd

Browse files
committed
fix: update url for new client if present
1 parent 312c6d3 commit ea4a5cd

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

packages/client/lib/client/enterprise-maintenance-manager.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,21 @@ export default class EnterpriseMaintenanceManager {
182182

183183
dbgMaintenance("Creating new tmp client");
184184
let start = performance.now();
185-
const tmpClient = this.#client.duplicate({
186-
socket: {
187-
...this.#options.socket,
188-
host,
189-
port,
190-
},
191-
});
185+
186+
const tmpOptions = this.#options;
187+
// If the URL is provided, it takes precedense
188+
if(tmpOptions.url) {
189+
const u = new URL(tmpOptions.url);
190+
u.hostname = host;
191+
u.port = String(port);
192+
tmpOptions.url = u.toString();
193+
} else {
194+
tmpOptions.socket = {
195+
...tmpOptions.socket,
196+
host, port
197+
}
198+
}
199+
const tmpClient = this.#client.duplicate(tmpOptions);
192200
dbgMaintenance(`Tmp client created in ${( performance.now() - start ).toFixed(2)}ms`);
193201
dbgMaintenance(`Connecting tmp client: ${host}:${port}`);
194202
start = performance.now();

0 commit comments

Comments
 (0)