[GH-ISSUE #3590] [Issue]: Blank TZ in .env.example forces Node to UTC/Etc/Unknown #1943

Closed
opened 2026-10-21 05:44:00 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @SpicyMarinara on GitHub (Jul 14, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3590

Originally assigned to: @SpicyMarinara on GitHub.

Summary

.env.example includes an active blank TZ= assignment. When copied to .env, Node treats the blank timezone as Etc/Unknown/UTC, causing server-side scheduling and date logic to run on the wrong local day.

Expected behavior

A blank or omitted timezone should allow Node to use the host timezone, or the template should not set TZ unless the user explicitly chooses an IANA timezone.

Actual behavior

Copying .env.example with TZ= causes process.env.TZ to be blank. Node resolves the timezone as Etc/Unknown and uses UTC for local Date operations, causing Noodle automatic refresh and other server-side schedules to run against the UTC day instead of the user's local day.

Steps to reproduce

  1. Run node -e 'console.log(Intl.DateTimeFormat().resolvedOptions().timeZone, new Date().toString())' with TZ unset and observe the host timezone, e.g. America/New_York, GMT-0400.
  2. Run the same command with TZ="" and observe Etc/Unknown, GMT+0000.
  3. Copy .env.example to .env without changing the active TZ= line.
  4. Start Marinara Engine and enable Noodle automatic refresh.
  5. Open the Noodle schedule UI and observe that it reports Etc/Unknown and distributes activity slots across the UTC day.

Environment

  • Marinara Engine version: Not provided
  • Install type: other
  • OS + version: macOS 26.5.2 build 25F84
  • Browser or app shell: Not provided

Logs, screenshots, or video

Reported command evidence: with TZ unset, Node reports America/New_York and GMT-0400; with TZ="", Node reports Etc/Unknown and GMT+0000. Node.js v24.17.0, ICU 78.3. No screenshots or video provided.

Additional context

Confirmed workaround: set an explicit IANA timezone such as TZ=America/New_York in .env and fully restart; Noodle then reports America/New_York and schedules against the local day. Reported affected areas include noodle-refresh-scheduler.service.ts, conversation presence/autonomous scheduling services using local getDay()/getHours()/getMinutes(), server-triggered autonomous generation lacking userTimeZone/promptTimeZone, awareness date windows, conversation memory context, scene summary date stamps, and tool/agent date macros. Proposed fixes: comment out the example timezone in .env.example, treat blank or whitespace-only TZ as unset in runtime config, warn in the UI when timezone resolves to Etc/Unknown, and pass explicit user/chat timezone to server-side scheduling and macro contexts.

Discord thread: [Config/Timezone] Blank TZ= forces Node to UTC/Etc/Unknown and affects scheduling
Discord thread link: https://discord.com/channels/1417099416812392641/1526408327939227838
Requested by: Marinara (marinara_spaghetti, Discord ID 169561011928432653)

Discord thread transcript (4 messages)
[2026-07-14T02:01:44.676Z] pod042: Sec, the prof’s rewriting the report.
[Discord message: https://discord.com/channels/1417099416812392641/1526408327939227838/1526408327939227838]

[2026-07-14T02:30:38.231Z] pod042: [Config/Timezone] Blank TZ= forces Node to UTC/Etc/Unknown and affects scheduling
[Discord message: https://discord.com/channels/1417099416812392641/1526408327939227838/1526415598995902634]

[2026-07-14T02:38:27.037Z] pod042: ## [Config/Timezone] Blank `TZ=` in `.env.example` forces Node to UTC/`Etc/Unknown`, breaking Noodle and Conversation scheduling

### Environment

- macOS 26.5.2 (build 25F84)
- Node.js v24.17.0, ICU 78.3
- Marinara Engine (local install, `.env` created from `.env.example`)

### Summary

`.env.example` ships an **active blank assignment** at line 15:

` ` `env
TZ=
` ` `

When a user copies the template, `dotenv` loads that blank value into `process.env.TZ` verbatim. In Node, an empty `TZ` does **not** mean "auto-detect" — it suppresses host timezone discovery, causing `Intl` to report `Etc/Unknown` and all local `Date` operations (`getHours()`, `getDay()`, etc.) to use UTC.

Everything server-side that relies on the process-local calendar then silently operates on the UTC day instead of the user's local day. The bug is easy to miss because the browser still renders post timestamps in the user's local timezone, so the UI looks normal while behavior is wrong.

### Reproduction (confirmed on this machine)

1. `node -e 'console.log(Intl.DateTimeFormat().resolvedOptions().timeZone, new Date().toString())'` with `TZ` **unset** → `America/New_York`, GMT-0400. ✅
2. Same command with `TZ=""` (blank) → `Etc/Unknown`, GMT+0000. ❌
3. Copy `.env.example` to `.env` (keeping `TZ=`), start Marinara, enable Noodle automatic refresh.
4. Noodle's schedule UI shows `Etc/Unknown`; automatic activity slots are distributed across the UTC day, so accounts post during the user's local nighttime.

So this is a **configuration-template bug**, not a Node install or OS timezone-discovery failure.
[Discord message: https://discord.com/channels/1417099416812392641/1526408327939227838/1526417565310517330]

[2026-07-14T02:38:30.563Z] pod042: ### Confirmed impact

**1. Noodle automatic refresh scheduler** (`noodle-refresh-scheduler.service.ts`)
Daily activity slots are generated across the server-local day. With blank `TZ`, that day is UTC, so accounts appear active at locally inappropriate hours. Verified before/after: setting `TZ=America/New_York` and restarting changed the reported zone from `Etc/Unknown` to `America/New_York` and reconciled the schedule.

**2. Conversation schedules and autonomous messaging** (largest sibling issue)
- `packages/shared/src/utils/conversation-presence.ts` and `packages/server/src/services/conversation/{schedule,autonomous,intent,server-autonomous-scheduler}.service.ts` use local `getDay()`/`getHours()`/`getMinutes()` to decide character presence (awake/asleep/offline), autonomous intents (good morning / good night / meal break), daily autonomous message budget resets, and schedule staleness.
- Browser-triggered generation is mostly protected because the client sends `userTimeZone` to `/api/generate`.
- **Server-triggered autonomous generation is not:** the internal `/api/generate` request built in `server-autonomous-scheduler.service.ts` includes no `userTimeZone`/`promptTimeZone` field (verified by source search), so unless the chat has an explicit `promptTimeZone` in metadata, it falls back to the server clock. Eligibility and intent selection also run against server-local time before generation.

**3. Cross-chat awareness & memories** (conditional)
- `awareness.service.ts`: labels use the browser timezone, but query windows for "today"/"yesterday"/"last night" are built from server-local midnight — labels can look right while the selected messages straddle the wrong day boundary.
- `conversation-memory-context.ts`: "today's" character memories keyed to server-local midnight.

**4. Scene summaries** (conditional)
- `scene.routes.ts` stamps completed scene summaries/memories with the server-local calendar date; scenes ending near the date boundary can get the wrong date.

**5. Custom-tool / agent date macros** (confirmed inconsistency)
- `tool-resolution-runtime.ts` lines 240–244 build the hidden tool context with `date: now.toISOString().slice(0, 10)` (**UTC**) but `time: now.toTimeString().slice(0, 5)` and `weekday: now.toLocaleDateString(...)` (**server-local**). Even with a correct `TZ`, these fields can disagree about which day it is around midnight; with blank `TZ` they're consistently wrong for the user.
- Agent-template `{{date}}`/`{{time}}`/weekday macros likewise don't receive the browser timezone.

**6. Cosmetic only**
- Plaintext chat-export timestamps, autogenerated stash names, ZIP/DOS modification times.

### Not affected

Stored ISO/epoch timestamps, expirations, cooldowns, retry delays, inactivity timers (all duration- or UTC-based), and browser-rendered message timestamps.

### Workaround (confirmed)

Set an IANA timezone in `.env` and fully restart:

` ` `env
TZ=America/New_York
` ` `

After restart, Noodle reports `America/New_York` and schedules against the local day.

### Proposed fixes

1. **Template:** change `.env.example` line 15 to a commented example: `# TZ=America/New_York`.
2. **Loader hardening:** in `runtime-config.ts`, treat blank/whitespace-only `TZ` as unset (delete it from `process.env` before anything reads it).
3. **UI warning:** when the scheduler timezone resolves to `Etc/Unknown`, surface an actionable warning in the Noodle schedule UI.
4. **Longer-term:** pass an explicit chat/user timezone into server-autonomous generation, awareness date windows, scene date stamps, and the tool/agent macro context — and fix the UTC/local mix in `tool-resolution-runtime.ts` so `date`, `time`, and `weekday` come from the same clock.
[Discord message: https://discord.com/channels/1417099416812392641/1526408327939227838/1526417580099895326]

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @SpicyMarinara on GitHub (Jul 14, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3590 Originally assigned to: @SpicyMarinara on GitHub. ## Summary `.env.example` includes an active blank `TZ=` assignment. When copied to `.env`, Node treats the blank timezone as `Etc/Unknown`/UTC, causing server-side scheduling and date logic to run on the wrong local day. ## Expected behavior A blank or omitted timezone should allow Node to use the host timezone, or the template should not set `TZ` unless the user explicitly chooses an IANA timezone. ## Actual behavior Copying `.env.example` with `TZ=` causes `process.env.TZ` to be blank. Node resolves the timezone as `Etc/Unknown` and uses UTC for local `Date` operations, causing Noodle automatic refresh and other server-side schedules to run against the UTC day instead of the user's local day. ## Steps to reproduce 1. Run `node -e 'console.log(Intl.DateTimeFormat().resolvedOptions().timeZone, new Date().toString())'` with `TZ` unset and observe the host timezone, e.g. `America/New_York`, GMT-0400. 2. Run the same command with `TZ=""` and observe `Etc/Unknown`, GMT+0000. 3. Copy `.env.example` to `.env` without changing the active `TZ=` line. 4. Start Marinara Engine and enable Noodle automatic refresh. 5. Open the Noodle schedule UI and observe that it reports `Etc/Unknown` and distributes activity slots across the UTC day. ## Environment - Marinara Engine version: Not provided - Install type: other - OS + version: macOS 26.5.2 build 25F84 - Browser or app shell: Not provided ## Logs, screenshots, or video Reported command evidence: with `TZ` unset, Node reports `America/New_York` and GMT-0400; with `TZ=""`, Node reports `Etc/Unknown` and GMT+0000. Node.js v24.17.0, ICU 78.3. No screenshots or video provided. ## Additional context Confirmed workaround: set an explicit IANA timezone such as `TZ=America/New_York` in `.env` and fully restart; Noodle then reports `America/New_York` and schedules against the local day. Reported affected areas include `noodle-refresh-scheduler.service.ts`, conversation presence/autonomous scheduling services using local `getDay()`/`getHours()`/`getMinutes()`, server-triggered autonomous generation lacking `userTimeZone`/`promptTimeZone`, awareness date windows, conversation memory context, scene summary date stamps, and tool/agent date macros. Proposed fixes: comment out the example timezone in `.env.example`, treat blank or whitespace-only `TZ` as unset in runtime config, warn in the UI when timezone resolves to `Etc/Unknown`, and pass explicit user/chat timezone to server-side scheduling and macro contexts. Discord thread: [Config/Timezone] Blank TZ= forces Node to UTC/Etc/Unknown and affects scheduling Discord thread link: https://discord.com/channels/1417099416812392641/1526408327939227838 Requested by: Marinara (marinara_spaghetti, Discord ID 169561011928432653) <details> <summary>Discord thread transcript (4 messages)</summary> ```text [2026-07-14T02:01:44.676Z] pod042: Sec, the prof’s rewriting the report. [Discord message: https://discord.com/channels/1417099416812392641/1526408327939227838/1526408327939227838] [2026-07-14T02:30:38.231Z] pod042: [Config/Timezone] Blank TZ= forces Node to UTC/Etc/Unknown and affects scheduling [Discord message: https://discord.com/channels/1417099416812392641/1526408327939227838/1526415598995902634] [2026-07-14T02:38:27.037Z] pod042: ## [Config/Timezone] Blank `TZ=` in `.env.example` forces Node to UTC/`Etc/Unknown`, breaking Noodle and Conversation scheduling ### Environment - macOS 26.5.2 (build 25F84) - Node.js v24.17.0, ICU 78.3 - Marinara Engine (local install, `.env` created from `.env.example`) ### Summary `.env.example` ships an **active blank assignment** at line 15: ` ` `env TZ= ` ` ` When a user copies the template, `dotenv` loads that blank value into `process.env.TZ` verbatim. In Node, an empty `TZ` does **not** mean "auto-detect" — it suppresses host timezone discovery, causing `Intl` to report `Etc/Unknown` and all local `Date` operations (`getHours()`, `getDay()`, etc.) to use UTC. Everything server-side that relies on the process-local calendar then silently operates on the UTC day instead of the user's local day. The bug is easy to miss because the browser still renders post timestamps in the user's local timezone, so the UI looks normal while behavior is wrong. ### Reproduction (confirmed on this machine) 1. `node -e 'console.log(Intl.DateTimeFormat().resolvedOptions().timeZone, new Date().toString())'` with `TZ` **unset** → `America/New_York`, GMT-0400. ✅ 2. Same command with `TZ=""` (blank) → `Etc/Unknown`, GMT+0000. ❌ 3. Copy `.env.example` to `.env` (keeping `TZ=`), start Marinara, enable Noodle automatic refresh. 4. Noodle's schedule UI shows `Etc/Unknown`; automatic activity slots are distributed across the UTC day, so accounts post during the user's local nighttime. So this is a **configuration-template bug**, not a Node install or OS timezone-discovery failure. [Discord message: https://discord.com/channels/1417099416812392641/1526408327939227838/1526417565310517330] [2026-07-14T02:38:30.563Z] pod042: ### Confirmed impact **1. Noodle automatic refresh scheduler** (`noodle-refresh-scheduler.service.ts`) Daily activity slots are generated across the server-local day. With blank `TZ`, that day is UTC, so accounts appear active at locally inappropriate hours. Verified before/after: setting `TZ=America/New_York` and restarting changed the reported zone from `Etc/Unknown` to `America/New_York` and reconciled the schedule. **2. Conversation schedules and autonomous messaging** (largest sibling issue) - `packages/shared/src/utils/conversation-presence.ts` and `packages/server/src/services/conversation/{schedule,autonomous,intent,server-autonomous-scheduler}.service.ts` use local `getDay()`/`getHours()`/`getMinutes()` to decide character presence (awake/asleep/offline), autonomous intents (good morning / good night / meal break), daily autonomous message budget resets, and schedule staleness. - Browser-triggered generation is mostly protected because the client sends `userTimeZone` to `/api/generate`. - **Server-triggered autonomous generation is not:** the internal `/api/generate` request built in `server-autonomous-scheduler.service.ts` includes no `userTimeZone`/`promptTimeZone` field (verified by source search), so unless the chat has an explicit `promptTimeZone` in metadata, it falls back to the server clock. Eligibility and intent selection also run against server-local time before generation. **3. Cross-chat awareness & memories** (conditional) - `awareness.service.ts`: labels use the browser timezone, but query windows for "today"/"yesterday"/"last night" are built from server-local midnight — labels can look right while the selected messages straddle the wrong day boundary. - `conversation-memory-context.ts`: "today's" character memories keyed to server-local midnight. **4. Scene summaries** (conditional) - `scene.routes.ts` stamps completed scene summaries/memories with the server-local calendar date; scenes ending near the date boundary can get the wrong date. **5. Custom-tool / agent date macros** (confirmed inconsistency) - `tool-resolution-runtime.ts` lines 240–244 build the hidden tool context with `date: now.toISOString().slice(0, 10)` (**UTC**) but `time: now.toTimeString().slice(0, 5)` and `weekday: now.toLocaleDateString(...)` (**server-local**). Even with a correct `TZ`, these fields can disagree about which day it is around midnight; with blank `TZ` they're consistently wrong for the user. - Agent-template `{{date}}`/`{{time}}`/weekday macros likewise don't receive the browser timezone. **6. Cosmetic only** - Plaintext chat-export timestamps, autogenerated stash names, ZIP/DOS modification times. ### Not affected Stored ISO/epoch timestamps, expirations, cooldowns, retry delays, inactivity timers (all duration- or UTC-based), and browser-rendered message timestamps. ### Workaround (confirmed) Set an IANA timezone in `.env` and fully restart: ` ` `env TZ=America/New_York ` ` ` After restart, Noodle reports `America/New_York` and schedules against the local day. ### Proposed fixes 1. **Template:** change `.env.example` line 15 to a commented example: `# TZ=America/New_York`. 2. **Loader hardening:** in `runtime-config.ts`, treat blank/whitespace-only `TZ` as unset (delete it from `process.env` before anything reads it). 3. **UI warning:** when the scheduler timezone resolves to `Etc/Unknown`, surface an actionable warning in the Noodle schedule UI. 4. **Longer-term:** pass an explicit chat/user timezone into server-autonomous generation, awareness date windows, scene date stamps, and the tool/agent macro context — and fix the UTC/local mix in `tool-resolution-runtime.ts` so `date`, `time`, and `weekday` come from the same clock. [Discord message: https://discord.com/channels/1417099416812392641/1526408327939227838/1526417580099895326] ``` </details> ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:44:00 +07:00
  • closed this issue
  • added the
    in-pr
    bug
    labels
Author
Owner

@SpicyMarinara commented on GitHub (Jul 14, 2026):

Owned in draft PR #3591. I’m addressing the blank template/runtime value plus the explicit server scheduling and calendar-context paths described in this report.

<!-- gh-comment-id:4967184461 --> @SpicyMarinara commented on GitHub (Jul 14, 2026): Owned in draft PR #3591. I’m addressing the blank template/runtime value plus the explicit server scheduling and calendar-context paths described in this report.
Author
Owner

@SpicyMarinara commented on GitHub (Jul 14, 2026):

Implemented in draft PR #3591. The fix removes the active blank TZ= template value, normalizes legacy blank/whitespace runtime values to unset, warns in Noodle when timezone detection is unresolved, and persists the browser timezone per chat for autonomous schedules, temporal awareness, daily memories, and tool macros. Added DST-aware regression coverage; pnpm check, timezone/Noodle/prompt regressions, and the UI smoke suite all pass.

<!-- gh-comment-id:4967284632 --> @SpicyMarinara commented on GitHub (Jul 14, 2026): Implemented in draft PR #3591. The fix removes the active blank `TZ=` template value, normalizes legacy blank/whitespace runtime values to unset, warns in Noodle when timezone detection is unresolved, and persists the browser timezone per chat for autonomous schedules, temporal awareness, daily memories, and tool macros. Added DST-aware regression coverage; `pnpm check`, timezone/Noodle/prompt regressions, and the UI smoke suite all pass.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1943
No description provided.