Remove init_script system timezone fallback that poisons storage (#560)

The else branch in _build_init_script() reads the system timezone via
Intl.DateTimeFormat().resolvedOptions().timeZone and stores it via
setTimezone(). When geoip resolves a different timezone (set later via
CAMOU_CONFIG/launch_options), the storage value from the init_script
takes precedence — workers read the wrong timezone and the C++ MaskConfig
fallback (PR #546) is never reached.

Fix: only call setTimezone() when an explicit timezone value is provided.
When omitted, timezone propagation is handled entirely by the C++ side
(SetNewDocument + TimezoneManager::GetTimezone MaskConfig fallback).

Companion to #546 (Fix worker timezone leak when using geoip/proxy).

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ruben Vereecken
2026-04-14 19:24:24 +01:00
committed by GitHub
parent 88f5b0c7a1
commit 40fbce61e4
+6 -5
View File
@@ -373,16 +373,17 @@ def _build_init_script(values: Dict[str, Any]) -> str:
f' if (typeof w.setScreenColorDepth === "function") w.setScreenColorDepth({scd});'
)
# Timezone (always call to trigger self-destruct)
# Timezone — only call setTimezone() when we have an explicit value.
# Without this, the C++ MaskConfig fallback (from CAMOU_CONFIG set by geoip
# in launch_options) handles timezone for both main thread and workers via
# SetNewDocument() and TimezoneManager::GetTimezone().
# The old fallback read system TZ and poisoned RoverfoxStorageManager,
# preventing MaskConfig from ever being consulted.
tz = values.get('timezone')
if tz:
lines.append(
f' if (typeof w.setTimezone === "function") w.setTimezone({_json.dumps(tz)});'
)
else:
lines.append(
' if (typeof w.setTimezone === "function") w.setTimezone(Intl.DateTimeFormat().resolvedOptions().timeZone);'
)
# WebRTC IP
ip = values.get('webrtcIP')