Skip to content

Commit c593560

Browse files
committed
fix: publications not becoming ready when returning null
1 parent 91e6a40 commit c593560

File tree

1 file changed

+4
-2
lines changed
  • meteor/server/publications/lib

1 file changed

+4
-2
lines changed

meteor/server/publications/lib/lib.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@ export function meteorPublishUnsafe(
5151

5252
const publicationGauge = MeteorPublicationsGauge.labels({ publication: name })
5353

54-
Meteor.publish(name, function (...args: any[]): any {
54+
Meteor.publish(name, async function (...args: any[]): Promise<any> {
5555
publicationGauge.inc()
5656
this.onStop(() => publicationGauge.dec())
5757

58-
return callback.apply(protectStringObject<Subscription, 'userId'>(this), args) || []
58+
const callbackRes = await callback.apply(protectStringObject<Subscription, 'userId'>(this), args)
59+
// If no value is returned, return an empty array so that meteor marks the subscription as ready
60+
return callbackRes || []
5961
})
6062
}
6163

0 commit comments

Comments
 (0)