Skip to content

Commit 4405ddf

Browse files
committed
fix: accept unknown bootstrap mode values gracefully instead of failing
The BootstrapEnvelopeSchema used Schema.optional(RuntimeMode) for the mode field, which caused schema decode to fail with a BootstrapError when an unrecognized mode string was sent (e.g. during a version mismatch between the desktop launcher and server). This prevented the server from starting. Restore the graceful fallback behavior by accepting any string in the bootstrap envelope schema and filtering to valid RuntimeMode values at resolution time, falling back to 'web' for unrecognized values.
1 parent f306805 commit 4405ddf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

apps/server/src/cli.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ import { runServer } from "./server";
1717

1818
const PortSchema = Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 65535 }));
1919

20+
const isRuntimeMode = Schema.is(RuntimeMode);
21+
2022
const BootstrapEnvelopeSchema = Schema.Struct({
21-
mode: Schema.optional(RuntimeMode),
23+
mode: Schema.optional(Schema.String),
2224
port: Schema.optional(PortSchema),
2325
host: Schema.optional(Schema.String),
2426
t3Home: Schema.optional(Schema.String),
@@ -148,7 +150,9 @@ export const resolveServerConfig = (
148150
resolveOptionPrecedence(
149151
flags.mode,
150152
Option.fromUndefinedOr(env.mode),
151-
Option.flatMap(bootstrapEnvelope, (bootstrap) => Option.fromUndefinedOr(bootstrap.mode)),
153+
Option.flatMap(bootstrapEnvelope, (bootstrap) =>
154+
Option.filter(Option.fromUndefinedOr(bootstrap.mode), isRuntimeMode),
155+
),
152156
),
153157
() => "web",
154158
);

0 commit comments

Comments
 (0)