Commit 8a7adc0
committed
fix(kernel-cli): move LOG_LEVELS above file-scope logger to avoid TDZ
The demo branch's file-scope logger construction hit a temporal-
dead-zone reference because `makeFileTransport(logPath,
resolveMinLogLevel())` runs at module top and `resolveMinLogLevel`
uses `LOG_LEVELS`, which was declared as a `const` further down
the file. Function declarations hoist but `const` bindings stay
in TDZ until execution reaches them, so the daemon child crashed
at module init with:
ReferenceError: Cannot access 'LOG_LEVELS' before initialization
The crash happened before the fatal-handler install ran, and the
child was spawned with stdio: 'ignore', so the failure surfaced
only as a 30-second polling timeout ("Daemon did not start").
Move `LOG_LEVELS`, `LogLevelName`, and `resolveMinLogLevel()`
above the module-scope logger construction. Fixes the demo
branch; PR #966 (main-based) is unaffected because its transport
factory doesn't reference `LOG_LEVELS`.1 parent ec393ff commit 8a7adc0
1 file changed
Lines changed: 30 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
14 | 44 | | |
15 | 45 | | |
16 | 46 | | |
| |||
138 | 168 | | |
139 | 169 | | |
140 | 170 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | 171 | | |
169 | 172 | | |
170 | 173 | | |
| |||
0 commit comments