fix(discord): discard a thread created for a replaced parent channel, test the notify timeout, document the bridge invariants

- a thread creation that finishes after the parent channel changed is dropped, and a finished creation only clears its own pending entry
- postJson takes an optional timeout, pinned by a test against a server that never answers
- drop the flat discord-bridge.json fallback
- add a Discord bridge section to architecture-invariants
This commit is contained in:
Devvyn committed 2026-10-30 06:42:17 +08:00
1 parent 1ab54b9e9b
commit dc22519adb
5 files changed
+93 -47

No files matched your search

+4 -3
View File
@@ -33,11 +33,12 @@ export interface NotifyResult {
export type JsonPost = (
apiUrl: string,
apiPath: string,
payload: unknown
payload: unknown,
timeoutMs?: number
) => Promise<{ status: number; error?: string; delivery?: { ok: boolean; error?: string } }>;
/** POST JSON to the Codeman API with the same credentials `codeman attach` uses. Status 0 means no answer. */
export const postJson: JsonPost = (apiUrl, apiPath, payload) => {
export const postJson: JsonPost = (apiUrl, apiPath, payload, timeoutMs = REQUEST_TIMEOUT_MS) => {
const { username, password } = readCodemanCredentials();
const url = new URL(apiPath, apiUrl);
const body = JSON.stringify(payload);
@@ -58,7 +59,7 @@ export const postJson: JsonPost = (apiUrl, apiPath, payload) => {
path: `${url.pathname}${url.search}`,
rejectUnauthorized: false,
headers,
timeout: REQUEST_TIMEOUT_MS,
timeout: timeoutMs,
},
(res) => {
let text = '';