Skip to content

fix: do not emit "error" events #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
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