fix(pdf-import): 분석 타임아웃 120s→300s 확대 — 서버 정상 완료 직전 클라이언트 abort 방지
[작업내용] : - 서버가 120,011ms 에 200 으로 정상 완료했는데 클라이언트 AbortController 가 정확히 120,000ms 에 fetch 를 끊어 타임아웃 toast 가 뜨던 문제 — gemini-3.1-pro-preview(thinking 비활성 불가) + MEDIA_RESOLUTION_HIGH PDF 분석은 정상 응답도 2분을 넘길 수 있어 300초로 확대 - 추후 진단용으로 서버에 단계별 소요시간(fileReady/generate) debug 로그 추가 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
8768182fa8
commit
f46dc788cc
@ -195,6 +195,7 @@ export async function POST(req) {
|
|||||||
|
|
||||||
const buffer = Buffer.from(await file.arrayBuffer())
|
const buffer = Buffer.from(await file.arrayBuffer())
|
||||||
|
|
||||||
|
const uploadStarted = Date.now()
|
||||||
const uploadResult = await fileManager.uploadFile(buffer, {
|
const uploadResult = await fileManager.uploadFile(buffer, {
|
||||||
mimeType: 'application/pdf',
|
mimeType: 'application/pdf',
|
||||||
displayName: file.name || 'floor-plan.pdf',
|
displayName: file.name || 'floor-plan.pdf',
|
||||||
@ -202,6 +203,7 @@ export async function POST(req) {
|
|||||||
uploadedFileName = uploadResult.file.name
|
uploadedFileName = uploadResult.file.name
|
||||||
|
|
||||||
await waitForFileActive(fileManager, uploadedFileName)
|
await waitForFileActive(fileManager, uploadedFileName)
|
||||||
|
const fileReadyMs = Date.now() - uploadStarted
|
||||||
|
|
||||||
const genAI = new GoogleGenerativeAI(apiKey)
|
const genAI = new GoogleGenerativeAI(apiKey)
|
||||||
const model = genAI.getGenerativeModel({
|
const model = genAI.getGenerativeModel({
|
||||||
@ -217,6 +219,7 @@ export async function POST(req) {
|
|||||||
|
|
||||||
const prompt = buildPrompt({ pageMode, facadePages, floorPages })
|
const prompt = buildPrompt({ pageMode, facadePages, floorPages })
|
||||||
|
|
||||||
|
const generateStarted = Date.now()
|
||||||
const result = await model.generateContent([
|
const result = await model.generateContent([
|
||||||
{
|
{
|
||||||
fileData: {
|
fileData: {
|
||||||
@ -228,6 +231,7 @@ export async function POST(req) {
|
|||||||
])
|
])
|
||||||
|
|
||||||
const raw = result.response.text()
|
const raw = result.response.text()
|
||||||
|
logger.debug('[gemini/floor-plan] timing(ms)', { fileReady: fileReadyMs, generate: Date.now() - generateStarted })
|
||||||
logger.debug('[gemini/floor-plan] raw response', raw)
|
logger.debug('[gemini/floor-plan] raw response', raw)
|
||||||
logger.debug('[gemini/floor-plan] usageMetadata', result.response.usageMetadata)
|
logger.debug('[gemini/floor-plan] usageMetadata', result.response.usageMetadata)
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,9 @@ const PDF_MAX_FILE_BYTES = 20 * 1024 * 1024
|
|||||||
|
|
||||||
// 분석 요청 타임아웃(ms). 서버 라우트는 파일 처리(최대 60s)+generateContent 로 길어질 수 있어
|
// 분석 요청 타임아웃(ms). 서버 라우트는 파일 처리(최대 60s)+generateContent 로 길어질 수 있어
|
||||||
// 클라이언트에서 backstop 을 둔다. 이 시간을 넘기면 abort 하여 스피너가 영구 멈추지 않도록 한다.
|
// 클라이언트에서 backstop 을 둔다. 이 시간을 넘기면 abort 하여 스피너가 영구 멈추지 않도록 한다.
|
||||||
const PDF_ANALYZE_TIMEOUT_MS = 120 * 1000
|
// gemini-3.1-pro-preview 는 thinking 비활성화가 불가능 + MEDIA_RESOLUTION_HIGH PDF 분석이라
|
||||||
|
// 정상 응답도 2분을 넘길 수 있다(실측 120s). 서버 완료 직전에 클라이언트가 끊지 않도록 여유를 둔다.
|
||||||
|
const PDF_ANALYZE_TIMEOUT_MS = 300 * 1000
|
||||||
|
|
||||||
const PDF_PAGE_MODE = {
|
const PDF_PAGE_MODE = {
|
||||||
ALL: 'all',
|
ALL: 'all',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user