Skip to content
Closed
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ pool.query(`
`);

io.adapter(createAdapter(pool));

pool.on("error", (err) => {
// ...
});

io.listen(3000);
```

Expand Down
11 changes: 5 additions & 6 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export class PostgresAdapter extends Adapter {
try {
await this.onEvent(msg.payload);
} catch (err) {
this.emit("error", err);
debug("an error has occurred while handling the notification");
}
});

Expand All @@ -213,7 +213,6 @@ export class PostgresAdapter extends Adapter {

this.client = client;
} catch (err) {
this.emit("error", err);
debug("error while initializing client, scheduling reconnection...");
this.scheduleReconnection();
}
Expand Down Expand Up @@ -391,7 +390,7 @@ export class PostgresAdapter extends Adapter {
`DELETE FROM ${this.tableName} WHERE created_at < now() - interval '${this.cleanupInterval} milliseconds'`
);
} catch (err) {
this.emit("error", err);
debug("an error has occurred while cleaning up old payloads");
}
this.scheduleCleanup();
}, this.cleanupInterval);
Expand Down Expand Up @@ -426,11 +425,11 @@ export class PostgresAdapter extends Adapter {
this.channel,
payload,
]);

this.scheduleHeartbeat();
} catch (err) {
this.emit("error", err);
debug("an error has occurred while publishing a new notification");
}

this.scheduleHeartbeat();
}

private async publishWithAttachment(document: any) {
Expand Down