fix(gmail-watcher): prevent TDZ in settleProcess and guard exit handl… · openclaw/openclaw@94968c8
SebTardif
·
2026-05-26
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -102,6 +102,10 @@ function spawnGogServe(cfg: GmailHookRuntimeConfig): ChildProcess {
|
102 | 102 | }); |
103 | 103 | |
104 | 104 | child.on("exit", (code, signal) => { |
| 105 | +// If a newer watcher has replaced this child, do not respawn. |
| 106 | +if (watcherProcess !== null && watcherProcess !== child) { |
| 107 | +return; |
| 108 | +} |
105 | 109 | if (shuttingDown) { |
106 | 110 | return; |
107 | 111 | } |
@@ -134,6 +138,8 @@ function spawnGogServe(cfg: GmailHookRuntimeConfig): ChildProcess {
|
134 | 138 | function settleProcess(proc: ChildProcess): Promise<void> { |
135 | 139 | return new Promise<void>((resolve) => { |
136 | 140 | let settled = false; |
| 141 | +let escalation: ReturnType<typeof setTimeout> | undefined; |
| 142 | +let finalTimeout: ReturnType<typeof setTimeout> | undefined; |
137 | 143 | const settle = () => { |
138 | 144 | if (settled) { |
139 | 145 | return; |
@@ -150,15 +156,15 @@ function settleProcess(proc: ChildProcess): Promise<void> {
|
150 | 156 | |
151 | 157 | proc.kill("SIGTERM"); |
152 | 158 | |
153 | | -const escalation = setTimeout(() => { |
| 159 | +escalation = setTimeout(() => { |
154 | 160 | try { |
155 | 161 | proc.kill("SIGKILL"); |
156 | 162 | } catch { |
157 | 163 | // already dead |
158 | 164 | } |
159 | 165 | }, 3_000); |
160 | 166 | |
161 | | -const finalTimeout = setTimeout(() => { |
| 167 | +finalTimeout = setTimeout(() => { |
162 | 168 | if (!settled) { |
163 | 169 | log.warn("gog process did not exit after SIGKILL; giving up"); |
164 | 170 | settle(); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。