@@ -182,49 +182,38 @@ export function cpuConfigIsValid(endpoints: backend.Endpoint[]): void {
182182 * This is a breaking change to prevent dangerous infinite retry loops and confusing timeouts.
183183 */
184184export function validateTimeoutConfig ( endpoints : backend . Endpoint [ ] ) : void {
185- const invalidEndpoints = endpoints . filter ( ( ep ) => {
185+ const invalidEndpoints : { ep : backend . Endpoint ; limit : number } [ ] = [ ] ;
186+ for ( const ep of endpoints ) {
186187 const timeout = ep . timeoutSeconds ;
187188 if ( ! timeout ) {
188- return false ;
189+ continue ;
189190 }
191+
192+ let limit : number | undefined ;
190193 if ( ep . platform === "gcfv1" ) {
191- return timeout > MAX_V1_TIMEOUT_SECONDS ;
192- }
193- if ( backend . isEventTriggered ( ep ) ) {
194- return timeout > MAX_V2_EVENTS_TIMEOUT_SECONDS ;
195- }
196- if ( backend . isScheduleTriggered ( ep ) ) {
197- return timeout > MAX_V2_SCHEDULE_TIMEOUT_SECONDS ;
198- }
199- if ( backend . isTaskQueueTriggered ( ep ) ) {
200- return timeout > MAX_V2_TASK_QUEUE_TIMEOUT_SECONDS ;
194+ limit = MAX_V1_TIMEOUT_SECONDS ;
195+ } else if ( backend . isEventTriggered ( ep ) ) {
196+ limit = MAX_V2_EVENTS_TIMEOUT_SECONDS ;
197+ } else if ( backend . isScheduleTriggered ( ep ) ) {
198+ limit = MAX_V2_SCHEDULE_TIMEOUT_SECONDS ;
199+ } else if ( backend . isTaskQueueTriggered ( ep ) ) {
200+ limit = MAX_V2_TASK_QUEUE_TIMEOUT_SECONDS ;
201+ } else if ( backend . isHttpsTriggered ( ep ) || backend . isCallableTriggered ( ep ) ) {
202+ limit = MAX_V2_HTTP_TIMEOUT_SECONDS ;
201203 }
202- if ( backend . isHttpsTriggered ( ep ) || backend . isCallableTriggered ( ep ) ) {
203- return timeout > MAX_V2_HTTP_TIMEOUT_SECONDS ;
204+
205+ if ( limit !== undefined && timeout > limit ) {
206+ invalidEndpoints . push ( { ep, limit } ) ;
204207 }
205- return false ;
206- } ) ;
208+ }
209+
207210 if ( invalidEndpoints . length === 0 ) {
208211 return ;
209212 }
210213
211214 const invalidList = invalidEndpoints
212- . sort ( backend . compareFunctions )
213- . map ( ( ep ) => {
214- let limit = MAX_V2_HTTP_TIMEOUT_SECONDS ;
215- if ( ep . platform === "gcfv1" ) {
216- limit = MAX_V1_TIMEOUT_SECONDS ;
217- } else if ( backend . isEventTriggered ( ep ) ) {
218- limit = MAX_V2_EVENTS_TIMEOUT_SECONDS ;
219- } else if ( backend . isScheduleTriggered ( ep ) ) {
220- limit = MAX_V2_SCHEDULE_TIMEOUT_SECONDS ;
221- } else if ( backend . isTaskQueueTriggered ( ep ) ) {
222- limit = MAX_V2_TASK_QUEUE_TIMEOUT_SECONDS ;
223- } else {
224- limit = MAX_V2_HTTP_TIMEOUT_SECONDS ;
225- }
226- return `\t${ getFunctionLabel ( ep ) } : ${ ep . timeoutSeconds } s (limit: ${ limit } s)` ;
227- } )
215+ . sort ( ( a , b ) => backend . compareFunctions ( a . ep , b . ep ) )
216+ . map ( ( { ep, limit } ) => `\t${ getFunctionLabel ( ep ) } : ${ ep . timeoutSeconds } s (limit: ${ limit } s)` )
228217 . join ( "\n" ) ;
229218
230219 const msg =
0 commit comments