Преглед на файлове

fix(ui): keep an explicit zero happy-eyeballs delay across the round trip

Follow-up found in review: the wire normalizer still stripped
tryDelayMs when it equaled 0, but with the schema default now 250 a
reload rehydrates the missing field as 250 - a user who explicitly set
0 ("disabled", per the field's own placeholder) would see 250 and any
subsequent save would silently enable a delay they turned off. Keep
tryDelayMs on the wire unconditionally; it is the one happy-eyeballs
field whose presence changes xray's behavior.

Refs #5780
MHSanaei преди 1 ден
родител
ревизия
9d1a21b484
променени са 2 файла, в които са добавени 8 реда и са изтрити 1 реда
  1. 0 1
      frontend/src/lib/xray/stream-wire-normalize.ts
  2. 8 0
      frontend/src/test/stream-wire-normalize.test.ts

+ 0 - 1
frontend/src/lib/xray/stream-wire-normalize.ts

@@ -267,7 +267,6 @@ export function normalizeSockoptForWire(
   const he = out.happyEyeballs;
   if (isRecord(he)) {
     const heOut: Record<string, unknown> = { ...he };
-    if (heOut.tryDelayMs === 0) delete heOut.tryDelayMs;
     if (heOut.prioritizeIPv6 === false) delete heOut.prioritizeIPv6;
     if (heOut.interleave === 1) delete heOut.interleave;
     if (heOut.maxConcurrentTry === 4) delete heOut.maxConcurrentTry;

+ 8 - 0
frontend/src/test/stream-wire-normalize.test.ts

@@ -213,6 +213,14 @@ describe('normalizeSockoptForWire', () => {
 
     expect(out?.happyEyeballs).toEqual({ tryDelayMs: 250 });
   });
+
+  it('keeps an explicit tryDelayMs of 0 so it cannot rehydrate as the 250 default', () => {
+    const out = normalizeSockoptForWire({
+      happyEyeballs: { tryDelayMs: 0, prioritizeIPv6: true, interleave: 1, maxConcurrentTry: 4 },
+    });
+
+    expect(out?.happyEyeballs).toEqual({ tryDelayMs: 0, prioritizeIPv6: true });
+  });
 });
 
 describe('normalizeStreamSettingsForWire reality', () => {