@abide/bridge 0.3.0 → 0.3.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @abide/bridge
2
2
 
3
+ ## 0.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - cc6f899: a bridge stopped by SIGTERM, SIGINT or SIGHUP ends every Claude Code run it started before it exits ([`5847a59`](https://github.com/briancray/abide/commit/5847a59e0de0d45ed1ea11b526fda27c24490ebc))
8
+
3
9
  ## 0.3.0
4
10
 
5
11
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abide/bridge",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "description": "Connects the Claude Code on your machine to the assistant on an abide site",
6
6
  "license": "MIT",
package/src/bridge.ts CHANGED
@@ -162,6 +162,15 @@ export async function bridge(options: {
162
162
  }
163
163
 
164
164
  const turns = new Map<string, AbortController>()
165
+ // 44.31 — A SIGNAL ENDS THE RUNS WITH THE BRIDGE: exiting on one skips every `finally`, so a run
166
+ // still going would outlive it, orphaned.
167
+ const signals = { SIGHUP: 129, SIGINT: 130, SIGTERM: 143 } as const
168
+ const stopped = (signal: keyof typeof signals): void => {
169
+ for (const controller of turns.values()) controller.abort()
170
+ process.exit(signals[signal])
171
+ }
172
+ for (const signal of Object.keys(signals) as (keyof typeof signals)[])
173
+ process.on(signal, stopped)
165
174
  let asked = 0
166
175
  const secret = crypto.randomUUID()
167
176
  const shim = Bun.serve({
@@ -327,6 +336,8 @@ export async function bridge(options: {
327
336
  stream = resumed
328
337
  }
329
338
  } finally {
339
+ for (const signal of Object.keys(signals) as (keyof typeof signals)[])
340
+ process.off(signal, stopped)
330
341
  for (const controller of turns.values()) controller.abort()
331
342
  await flushing
332
343
  await flush()