Skip to content

Commit 1e610d4

Browse files
authored
Merge pull request #1496 from rocket-admin/backend_ai_logs
feat: enhance timeout settings for AI endpoints in TimeoutInterceptor
2 parents 4ce6ea4 + 857598b commit 1e610d4

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

backend/src/interceptors/timeout.interceptor.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,17 @@ import { Messages } from '../exceptions/text/messages.js';
55

66
@Injectable()
77
export class TimeoutInterceptor implements NestInterceptor {
8-
intercept(_context: ExecutionContext, next: CallHandler): Observable<any> {
9-
const timeoutMs = process.env.NODE_ENV !== 'test' ? 15000 : 200000;
8+
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
9+
const request = context.switchToHttp().getRequest();
10+
const isAIEndpoint = request.url.includes('/ai/v2/request/');
11+
const timeoutMs = isAIEndpoint
12+
? process.env.NODE_ENV !== 'test'
13+
? 300000
14+
: 600000
15+
: process.env.NODE_ENV !== 'test'
16+
? 15000
17+
: 200000;
18+
1019
return next.handle().pipe(
1120
timeout(timeoutMs),
1221
catchError((err) => {

0 commit comments

Comments
 (0)