fix: stabilize concurrent PDF parsing with LiteParse WASM#7318
fix: stabilize concurrent PDF parsing with LiteParse WASM#7318c121914yu wants to merge 4 commits into
Conversation
Coverage Report
File CoverageNo changed files found. |
|
✅ Docs Preview Deployed! 🔗 👀 Click here to visit preview 🕒 Time: 2026-07-16 21:02:48 (UTC+8) |
|
✅ Admin Preview Image Ready! 🕒 Time: 2026-07-16 19:29:33 (UTC+8) |
|
✅ Build Successful - Preview fastgpt Image for this PR: 🕒 Time: 2026-07-16 20:42:43 (UTC+8) |
There was a problem hiding this comment.
Pull request overview
This PR stabilizes concurrent PDF parsing by switching FastGPT’s file-reading worker from native @llamaindex/liteparse (PDFium/N-API) to @llamaindex/liteparse-wasm (WASM), adds in-flight request deduplication on the web side for selected endpoints, and reduces the default file parsing worker pool size from 10 to 5 across configs and docs.
Changes:
- Replace native LiteParse with LiteParse WASM in the readFile worker, including per-batch parser cleanup and a guarded PDF.js fallback only for WASM load/init failures.
- Add optional in-flight request deduplication in the web request helper and enable it for model list + sandbox package endpoints, with unit tests.
- Update worker build packaging (externalize/copy WASM runtime), Docker image verification, default worker concurrency, and related deployment/docs files.
Reviewed changes
Copilot reviewed 37 out of 38 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| projects/app/test/web/common/api/request.test.ts | Adds unit tests for in-flight request deduplication behavior. |
| projects/app/src/web/common/system/api.ts | Enables request deduplication for the “getMyModels” endpoint. |
| projects/app/src/web/common/api/request.ts | Implements optional in-flight request deduplication in the request wrapper. |
| projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeCode/api.ts | Enables request deduplication for sandbox package metadata fetches. |
| projects/app/scripts/build-workers.ts | Updates worker runtime packaging/externalization for LiteParse WASM. |
| projects/app/package.json | Replaces dependency from @llamaindex/liteparse to @llamaindex/liteparse-wasm. |
| projects/app/Dockerfile | Adds a runtime assertion to ensure the WASM binary exists in the final image. |
| projects/app/.env.template | Updates template defaults/formatting relevant to deployment config. |
| pnpm-workspace.yaml | Pins @llamaindex/liteparse-wasm version in the workspace catalog. |
| pnpm-lock.yaml | Updates lockfile entries to reflect LiteParse WASM dependency graph. |
| packages/service/worker/readFile/utils/LiteParse/pdfTextPostprocess.ts | Adjusts LiteParse-related type imports to local worker types. |
| packages/service/worker/readFile/utils/LiteParse/index.ts | Loads/initializes LiteParse WASM in-worker and frees parser per batch. |
| packages/service/worker/readFile/extension/pdf.ts | Updates fallback detection logic/messages from native-load errors to WASM-load/init errors. |
| packages/service/test/worker/readFile/utils/LiteParse/index.test.ts | Updates unit tests/mocks for LiteParse WASM init + parser free semantics. |
| packages/service/test/worker/readFile/integration.test.ts | Adds memory observation logging around PDF worker stress + pool destroy. |
| packages/service/test/worker/readFile/extension/pdf.test.ts | Updates fallback tests for LiteParse WASM load/init failures. |
| packages/service/test/worker/function.test.ts | Updates expectations for new default PARSE_FILE_WORKERS value (5). |
| packages/service/package.json | Replaces dependency from @llamaindex/liteparse to @llamaindex/liteparse-wasm. |
| packages/service/env.ts | Changes default PARSE_FILE_WORKERS from 10 to 5. |
| document/public/deploy/docker/v4.15/global/docker-compose.zilliz.yml | Updates default PARSE_FILE_WORKERS in deployment template. |
| document/public/deploy/docker/v4.15/global/docker-compose.seekdb.yml | Updates default PARSE_FILE_WORKERS in deployment template. |
| document/public/deploy/docker/v4.15/global/docker-compose.pg.yml | Updates default PARSE_FILE_WORKERS in deployment template. |
| document/public/deploy/docker/v4.15/global/docker-compose.opengauss.yml | Updates default PARSE_FILE_WORKERS in deployment template. |
| document/public/deploy/docker/v4.15/global/docker-compose.oceanbase.yml | Updates default PARSE_FILE_WORKERS in deployment template. |
| document/public/deploy/docker/v4.15/global/docker-compose.milvus.yml | Updates default PARSE_FILE_WORKERS in deployment template. |
| document/public/deploy/docker/v4.15/cn/docker-compose.zilliz.yml | Updates default PARSE_FILE_WORKERS in CN deployment template. |
| document/public/deploy/docker/v4.15/cn/docker-compose.seekdb.yml | Updates default PARSE_FILE_WORKERS in CN deployment template. |
| document/public/deploy/docker/v4.15/cn/docker-compose.pg.yml | Updates default PARSE_FILE_WORKERS in CN deployment template. |
| document/public/deploy/docker/v4.15/cn/docker-compose.opengauss.yml | Updates default PARSE_FILE_WORKERS in CN deployment template. |
| document/public/deploy/docker/v4.15/cn/docker-compose.oceanbase.yml | Updates default PARSE_FILE_WORKERS in CN deployment template. |
| document/public/deploy/docker/v4.15/cn/docker-compose.milvus.yml | Updates default PARSE_FILE_WORKERS in CN deployment template. |
| document/data/doc-last-modified.json | Updates doc last-modified timestamps for changed docs. |
| document/content/self-host/upgrading/4-15/4152.mdx | Documents the LiteParse/concurrency and request-dedup changes in CN upgrade notes. |
| document/content/self-host/upgrading/4-15/4152.en.mdx | Documents the LiteParse/concurrency and request-dedup changes in EN upgrade notes. |
| document/content/self-host/config/env.mdx | Updates documented default for PARSE_FILE_WORKERS (CN). |
| document/content/self-host/config/env.en.mdx | Updates documented default for PARSE_FILE_WORKERS (EN). |
| deploy/version/v4.15/docker-compose.template.yml | Updates default PARSE_FILE_WORKERS in deploy template. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| liteParseWasmModulePromise = (async () => { | ||
| try { | ||
| const wasmModule = await import('@llamaindex/liteparse-wasm'); | ||
| const wasmPath = workerRequire.resolve('@llamaindex/liteparse-wasm/liteparse_wasm_bg.wasm'); | ||
| const wasmBytes = await readFile(wasmPath); | ||
| await wasmModule.default({ module_or_path: wasmBytes }); |
What changed
@llamaindex/liteparseruntime with@llamaindex/liteparse-wasm2.0.8.PARSE_FILE_WORKERSvalue from 10 to 5 across runtime config, Docker Compose, Helm, tests, and Chinese/English documentation.The matching pro/admin worker packaging change is in draft PR labring/fastgpt-pro#1020; this PR pins that commit so CI can fetch the complete runtime.
Why
The native LiteParse/PDFium path could intermittently corrupt parser state under concurrent worker activity, producing errors such as
invalid PDF formatorpage not founduntil the service restarted. A WASM instance is isolated inside each worker thread, preserving file-level concurrency without sharing native PDFium global state.Validation
@fastgpt/servicesuite: 263 files passed, 1 skipped; 3,279 tests passed, 35 skipped.pnpm --filter app build:workerspnpm --filter @fastgpt/admin build:workerspnpm --filter app typecheckpnpm --filter @fastgpt/admin typecheckgit diff --check, and repository pre-commit hooks passed.