Skip to content

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

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/db-configdir-tdz
Open

fix(db): Fix TDZ ReferenceError in getConfigDir#1456
sentry[bot] wants to merge 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants