Skip to content

Commit 576177f

Browse files
authored
feat(pubsub): add maxListeners to subscription eventEmitter (#688)
1 parent 3e7f98f commit 576177f

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

packages/pg-pubsub/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const postgraphileOptions = {
6565
pluginHook,
6666
subscriptions: true, // Enable PostGraphile websocket capabilities
6767
simpleSubscriptions: true, // Add the `listen` subscription field
68+
subscriptionEventEmitterMaxListeners: 20, // Set max listeners on eventEmitter, 0 unlimited, 10 default
6869
websocketMiddlewares: [
6970
// Add whatever middlewares you need here, note that they should only
7071
// manipulate properties on req/res, they must not sent response data. e.g.:

packages/pg-pubsub/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ declare module "postgraphile" {
1313
interface PostGraphileOptions {
1414
simpleSubscriptions?: boolean;
1515
subscriptionAuthorizationFunction?: string;
16+
subscriptionEventEmitterMaxListeners?: number;
1617
}
1718
}
1819

@@ -56,6 +57,11 @@ const plugin: PostGraphilePlugin = {
5657

5758
["postgraphile:options"](incomingOptions, { pgPool }) {
5859
const eventEmitter = new EventEmitter();
60+
if (incomingOptions.subscriptionEventEmitterMaxListeners != null) {
61+
eventEmitter.setMaxListeners(
62+
incomingOptions.subscriptionEventEmitterMaxListeners
63+
);
64+
}
5965
const {
6066
simpleSubscriptions,
6167
subscriptionAuthorizationFunction,

0 commit comments

Comments
 (0)