@dbx-tools/tunnel 0.9.118 → 0.9.120

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/supervisor.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AppKitChildProcess } from "@dbx-tools/appkit/child-process";
2
2
  import type { ChildProcessResult } from "@dbx-tools/core/exec";
3
- import { asyncUtils, type Logger } from "@dbx-tools/shared-core";
3
+ import { asyncUtils, errorUtils, type Logger } from "@dbx-tools/shared-core";
4
4
 
5
5
  const STABLE_CONNECTION_MS = 60_000;
6
6
  /** How long to wait after a child start before the first public liveness probe. */
@@ -51,9 +51,11 @@ export function superviseProcessForever(options: ProcessSupervisorOptions): Proc
51
51
  const terminateChild = () => {
52
52
  const stoppingProcess = managedProcess;
53
53
  if (!stoppingProcess) return;
54
- void stoppingProcess
55
- .shutdown()
56
- .catch((error) => options.logger.error(`${options.name} did not stop`, { error }));
54
+ void stoppingProcess.shutdown().catch((error) =>
55
+ options.logger.error(`${options.name} did not stop`, {
56
+ error: errorUtils.toError(error),
57
+ }),
58
+ );
57
59
  };
58
60
 
59
61
  const stop = () => {
@@ -78,7 +80,7 @@ export function superviseProcessForever(options: ProcessSupervisorOptions): Proc
78
80
  if (!child) throw new Error(`${options.name} did not start a child process`);
79
81
  outcome = await processOutcome(managedProcess, child, controller.signal, options);
80
82
  } catch (error) {
81
- outcome = { error };
83
+ outcome = { error: errorUtils.toError(error) };
82
84
  } finally {
83
85
  managedProcess = undefined;
84
86
  }
@@ -94,7 +96,11 @@ export function superviseProcessForever(options: ProcessSupervisorOptions): Proc
94
96
  }
95
97
  };
96
98
 
97
- void run().catch((error) => options.logger.error(`${options.name} supervisor failed`, { error }));
99
+ void run().catch((error) =>
100
+ options.logger.error(`${options.name} supervisor failed`, {
101
+ error: errorUtils.toError(error),
102
+ }),
103
+ );
98
104
  return {
99
105
  stop,
100
106
  };
@@ -145,7 +151,9 @@ function processOutcome(
145
151
  } catch (error) {
146
152
  // Probe errors (DNS blips, timeouts) are not proof the tunnel is dead;
147
153
  // only an explicit unhealthy result triggers a restart.
148
- options.logger.debug(`${options.name} health probe errored; ignoring`, { error });
154
+ options.logger.debug(`${options.name} health probe errored; ignoring`, {
155
+ error: errorUtils.toError(error),
156
+ });
149
157
  healthy = true;
150
158
  }
151
159
  if (settled || signal.aborted) return;
@@ -171,7 +179,9 @@ function processOutcome(
171
179
  void managedProcess.shutdown().then(
172
180
  () => finish(outcome),
173
181
  (error) => {
174
- options.logger.error(`${options.name} did not stop`, { error });
182
+ options.logger.error(`${options.name} did not stop`, {
183
+ error: errorUtils.toError(error),
184
+ });
175
185
  finish(outcome);
176
186
  },
177
187
  );