fix: timeout in space assignment and return response in add

This commit is contained in:
Harshith Mullapudi 2025-09-01 19:17:26 +05:30
parent 084ad5be85
commit de94f67f7b
2 changed files with 5 additions and 5 deletions

View File

@ -14,8 +14,8 @@ const { action, loader } = createHybridActionApiRoute(
corsStrategy: "all", corsStrategy: "all",
}, },
async ({ body, authentication }) => { async ({ body, authentication }) => {
const response = addToQueue(body, authentication.userId); const response = await addToQueue(body, authentication.userId);
return json({ ...response }); return json({ success: true, id: response.id });
}, },
); );

View File

@ -174,7 +174,7 @@ async function checkAndTriggerSpacePatterns(
export const spaceAssignmentTask = task({ export const spaceAssignmentTask = task({
id: "space-assignment", id: "space-assignment",
maxDuration: 900, // 15 minutes timeout maxDuration: 1800, // 15 minutes timeout
run: async (payload: SpaceAssignmentPayload) => { run: async (payload: SpaceAssignmentPayload) => {
const { const {
userId, userId,
@ -550,7 +550,7 @@ async function processBatchAI(
requests: batchRequests, requests: batchRequests,
outputSchema: AssignmentResultSchema, outputSchema: AssignmentResultSchema,
maxRetries: 3, maxRetries: 3,
timeoutMs: 600000, // 10 minutes timeout timeoutMs: 1200000, // 10 minutes timeout
}); });
logger.info(`Batch AI job created: ${batchId}`, { logger.info(`Batch AI job created: ${batchId}`, {
@ -560,7 +560,7 @@ async function processBatchAI(
}); });
// Poll for completion with improved handling // Poll for completion with improved handling
const maxPollingTime = 780000; // 10 minutes const maxPollingTime = 1200000; // 13 minutes
const pollInterval = 5000; // 5 seconds const pollInterval = 5000; // 5 seconds
const startTime = Date.now(); const startTime = Date.now();