Skip to content
This repository was archived by the owner on Oct 23, 2026. It is now read-only.

fix(db): Fix TDZ ReferenceError in getConfigDir - #1456

Merged
BYK merged 1 commit into
mainfrom
seer/fix/db-configdir-tdz
Aug 25, 2026
Merged

BYK merged 1 commit into
mainfrom
seer/fix/db-configdir-tdz

Conversation

@sentry

@sentry sentry Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

This PR addresses a ReferenceError: Cannot access '_require' before initialization. that occurred in getConfigDir() within packages/cli/src/lib/db/index.ts.

The root cause was a Temporal Dead Zone (TDZ) issue: _require was declared as a const on line 13, but the static ESM import import { migrateFromJson } from "./migration.js" on line 17 is hoisted and evaluated earlier. If migration.js synchronously called getConfigDir() during its initialization, _require would not yet be assigned, leading to the ReferenceError.

The fix involves replacing the lazy _require("node:os") call for homedir with a standard static top-level import import { homedir } from "node:os";. This ensures homedir is available when getConfigDir() is called, regardless of module initialization order. The _require variable remains in the file for its other legitimate uses (e.g., lazy-loading telemetry).

Fixes CLI-22E

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@vercel

vercel Bot commented Aug 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cli Ready Ready Preview Aug 22, 2026 10:41pm

Request Review

@BYK
BYK merged commit 74f3075 into main Aug 25, 2026
29 checks passed
@BYK
BYK deleted the seer/fix/db-configdir-tdz branch August 25, 2026 08:51

This branch was successfully deployed

1 active deployment
Preview — 28ea621a Deployed Aug 22, 2026 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant