From 2b600fd4b7d2ffed053709a7ba7b4424d91b641a Mon Sep 17 00:00:00 2001 From: Sree Narayanan Date: Wed, 2 Sep 2026 00:33:22 +0400 Subject: [PATCH] fix(rivetkit): preserve engine bind defaults --- .../rivetkit/src/registry/config/index.ts | 8 ++++---- .../tests/registry-constructor.test.ts | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/rivetkit-typescript/packages/rivetkit/src/registry/config/index.ts b/rivetkit-typescript/packages/rivetkit/src/registry/config/index.ts index 60843f6e22..6d65c14849 100644 --- a/rivetkit-typescript/packages/rivetkit/src/registry/config/index.ts +++ b/rivetkit-typescript/packages/rivetkit/src/registry/config/index.ts @@ -225,7 +225,7 @@ export const RegistryConfigSchema = z engineHost: z .string() .optional() - .default(() => getRivetRunEngineHost() ?? ENGINE_HOST), + .transform((value) => value ?? getRivetRunEngineHost()), /** * @experimental * @@ -237,7 +237,7 @@ export const RegistryConfigSchema = z .min(1) .max(65_535) .optional() - .default(() => getRivetRunEnginePort() ?? ENGINE_PORT), + .transform((value) => value ?? getRivetRunEnginePort()), /** @experimental */ engineVersion: z .string() @@ -347,8 +347,8 @@ export const RegistryConfigSchema = z // Flatten the endpoint and apply defaults for namespace/token. const localEngineEndpoint = buildEngineEndpoint( - config.engineHost, - config.enginePort, + config.engineHost ?? ENGINE_HOST, + config.enginePort ?? ENGINE_PORT, ); const endpoint = config.startEngine ? localEngineEndpoint diff --git a/rivetkit-typescript/packages/rivetkit/tests/registry-constructor.test.ts b/rivetkit-typescript/packages/rivetkit/tests/registry-constructor.test.ts index 314bd9d328..c40a0aca85 100644 --- a/rivetkit-typescript/packages/rivetkit/tests/registry-constructor.test.ts +++ b/rivetkit-typescript/packages/rivetkit/tests/registry-constructor.test.ts @@ -108,6 +108,24 @@ describe("Registry constructor", () => { expect(config.publicEndpoint).toBe("http://127.0.0.1:7655"); }); + test("does not override the bind address for an explicit engine endpoint", async () => { + const config = RegistryConfigSchema.parse({ + use: { + test: testActor, + }, + startEngine: false, + endpoint: "http://127.0.0.1:7656", + }); + + const serveConfig = await buildServeConfig(config); + + expect(new URL(serveConfig.endpoint).origin).toBe( + "http://127.0.0.1:7656", + ); + expect(serveConfig.engineHost).toBeUndefined(); + expect(serveConfig.enginePort).toBeUndefined(); + }); + test("keeps endpoint separate from spawned local engine config", () => { const result = RegistryConfigSchema.safeParse({ use: {