Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/live/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,13 @@ export class Bus {
#startLoop(): void {
this.#loopPromise = (async () => {
while (this.#running) {
await this.#poll();
try {
await this.#poll();
} catch (e) {
// stop() flipped #running while a poll was in flight (or the
// schema vanished under us). Shutdown is not a poll failure.
if (this.#running) { throw e; }
}
const waiters = this.#oncePolled.splice(0);
for (const w of waiters) {
w();
Expand Down
4 changes: 3 additions & 1 deletion src/test-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ export const setupDb = (): void => {
});

afterAll(async () => {
await conn.execute(sql`DROP SCHEMA IF EXISTS ${db.scopedIdent(schema)} CASCADE`);
// Stop the poller first. Don't DROP SCHEMA here — a concurrent poll
// can race the drop (max: 1 pool, two-query poll). Next beforeAll
// already drops leftover schema.
await conn.close();
});
};
Expand Down
Loading