@@ -59,16 +59,16 @@ function wrapToFnIfNeeded<T, R>(possibleFn: T | ((a: R) => T)): (a: R) => T {
5959 return ( ) => possibleFn ;
6060}
6161
62- class AcceptAllAcceptor {
63- public shouldAccept ( ) : ContextAcceptanceResult {
62+ class AcceptAllAcceptor implements ContextAcceptor {
63+ public async shouldAccept ( ) : Promise < ContextAcceptanceResult > {
6464 return { accepted : true } ;
6565 }
6666
67- public shouldAcceptHttp ( ) : ContextAcceptanceResultHttp {
67+ public async shouldAcceptHttp ( ) : Promise < ContextAcceptanceResultHttp > {
6868 return { accepted : true } ;
6969 }
7070
71- public shouldAcceptWs ( ) : ContextAcceptanceResultWs {
71+ public async shouldAcceptWs ( ) : Promise < ContextAcceptanceResultWs > {
7272 return { accepted : true } ;
7373 }
7474}
@@ -475,7 +475,7 @@ export class CubejsServerCore {
475475
476476 protected async contextRejectionMiddleware ( req , res , next ) {
477477 if ( ! this . standalone ) {
478- const result = this . contextAcceptor . shouldAcceptHttp ( req . context ) ;
478+ const result = await this . contextAcceptor . shouldAcceptHttp ( req . context ) ;
479479 if ( ! result . accepted ) {
480480 res . writeHead ( result . rejectStatusCode ! , result . rejectHeaders ! ) ;
481481 res . send ( ) ;
@@ -707,9 +707,17 @@ export class CubejsServerCore {
707707 error : 'At least one context should be returned by scheduledRefreshContexts'
708708 } ) ;
709709 }
710- const contexts = allContexts . filter (
711- ( context ) => this . contextAcceptor . shouldAccept ( this . migrateBackgroundContext ( context ) ) . accepted
712- ) ;
710+
711+ const contexts = [ ] ;
712+
713+ for ( const allContext of allContexts ) {
714+ const res = await this . contextAcceptor . shouldAccept (
715+ this . migrateBackgroundContext ( allContext )
716+ ) ;
717+ if ( res . accepted ) {
718+ contexts . push ( allContext ) ;
719+ }
720+ }
713721
714722 const batchLimit = pLimit ( this . options . scheduledRefreshBatchSize ) ;
715723 return Promise . all (
0 commit comments