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

+20
View File
@@ -521,6 +521,26 @@ describe('DiscordBridge', () => {
b.stop();
});
it('drops a thread whose creation finished after the parent channel changed', async () => {
let release!: () => void;
const gate = new Promise<void>((r) => (release = r));
const b = bridge({}, async (url) => {
if (String(url).endsWith(`/channels/${PARENT}/threads`)) {
await gate;
return jsonRes({ id: THREAD });
}
return jsonRes({ id: 'msg' });
});
const first = b.notify(MSG);
await new Promise((r) => setTimeout(r, 10));
await writeDiscordConfig(dir, { ...CFG, parentChannelId: '777777777777777777' });
await b.reload();
release();
expect(await first).toMatchObject({ ok: false });
expect(await readThreadMap(dir)).toEqual({});
b.stop();
});
describe('sendTest', () => {
it('posts with the config it is given and leaves the live config alone', async () => {
const auth: string[] = [];