You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactors the import pipeline: renames FileTaskService to FileImportTaskService, expands HTML formatting to extract page icons, overhauls attachment processing with Confluence-aware logic and Draw.io handling, increases upload concurrency and indexing backoff, adjusts providers, and tweaks an editor hr style. Also updates a server submodule pointer.
ProseMirror hr: border-top reduced 2px→1px; removed vertical margin; no other changes.
EE submodule pointer apps/server/src/ee
Updated submodule reference SHA; no direct code changes.
Import service rename & wiring apps/server/src/integrations/import/import.module.ts, apps/server/src/integrations/import/processors/file-task.processor.ts, apps/server/src/integrations/import/services/file-import-task.service.ts
Renamed FileTaskService → FileImportTaskService; updated imports, providers, and constructor injection; logger updated; service now handles pageIcon from formatter and sets page.icon.
sequenceDiagram
autonumber
participant U as Import Job
participant P as FileTaskProcessor
participant S as FileImportTaskService
participant F as formatImportHtml (utils)
participant A as ImportAttachmentService
participant St as StorageService
participant Idx as Indexer
U->>P: enqueue(import-task)
P->>S: process(job)
S->>F: formatImportHtml(html, meta...)
Note right of F: Extract backlinks<br/>Remove Notion header/cover<br/>Detect pageIcon (Unicode)
F-->>S: { html, backlinks, pageIcon? }
S->>A: processAttachments(html, opts{..., isConfluenceImport?})
alt Confluence import
Note over A: Draw.io pairing + SVG generation
else Non-Confluence
Note over A: Skip Draw.io pairing
end
A->>St: upload attachments (concurrency=5)
A-->>S: transformed HTML
S->>Idx: schedule indexing (backoff=3m)
S-->>P: page created/updated (icon set if provided)
P-->>U: job complete
Loading
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~60 minutes
Possibly related PRs
fix: confluence drawio import #1518 — Touches the same import attachment service and Draw.io pairing/SVG embedding logic, with similar signature extensions and processing flow changes.
Poem
In cables of code I twitch my nose,
Draw.io blooms where the diagram grows.
Five hops upload, with backoff grace,
A page finds its icon, a Unicode face.
Imports march on—no stalls, no fright—
Thump-thump, I ship this change tonight. 🐇✨
✨ Finishing touches
📝 Generate Docstrings
🧪 Generate unit tests
Create PR with unit tests
Post copyable unit tests in a comment
Commit unit tests in branch fix/import
Tip
👮 Agentic pre-merge checks are now available in preview!
Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.
reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"mode: "warning"instructions: | Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).
Please share your feedback with us on this Discord post.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
Pre-merge checks
❌ Failed checks (2 warnings, 2 inconclusive)
Check name
Status
Explanation
Resolution
Out of Scope Changes Check
⚠️ Warning
There are out-of-scope changes in this PR: the client CSS tweak (apps/client/src/features/editor/styles/core.css) and the EE submodule pointer update (apps/server/src/ee) are unrelated to fixing import-task stalls and should be separated; renames and import-service refactors are borderline but generally relevant to the import flow.
Split unrelated cosmetic and repository-meta changes (the core.css change and the ee submodule bump) into separate PRs or commits and keep this PR focused on the import-task fixes, or clearly document why those changes must be bundled here to aid review and reduce scope.
Docstring Coverage
⚠️ Warning
Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%.
You can run @coderabbitai generate docstrings to improve docstring coverage.
Linked Issues Check
❓ Inconclusive
The changes modify the attachment pipeline, add per-element resolution, gate expensive Draw.io pairing to Confluence flows, and increase backoff for indexing which align with addressing import stalls reported in #1550; however the PR lacks reproduction logs, test coverage, or benchmark results demonstrating the stall is resolved on constrained hardware (4 vCPU / 4GB), and the increased concurrency may have side effects, so it is not possible to confirm the issue is fully fixed from the diff alone.
Add before/after logs or CI/integration tests that reproduce the stall, include benchmarks or a reproduction report on a 4 vCPU/4GB environment, and make concurrency/backoff settings configurable (with conservative defaults) so reviewers can verify the fix and rule out regressions.
Title Check
❓ Inconclusive
The current title "fix import" is related to the changeset because many import-related modules and attachment-processing behaviors were modified, but the title is overly terse and lacks specificity about what was fixed or its scope. Because it does not clearly communicate the primary change to a reviewer scanning history, the check is inconclusive.
Rename the PR to a concise, descriptive title such as "fix: page import task" or "fix(import): prevent attachment-related stalls (fixes #1550)" so the main change and scope are clear to reviewers and future readers.
✅ Passed checks (1 passed)
Check name
Status
Explanation
Description Check
✅ Passed
Check skipped - CodeRabbit’s high-level summary is enabled.
106-116: Early return leaks tmp files and leaves task unresolved when EE module is missing.
Returning here skips cleanup and status update, causing the worker to look “stalled.”
Throw to trigger failure handling and cleanup:
- } catch (err) {- this.logger.error(- 'Confluence import requested but EE module not bundled in this build',- );- return;- }+ } catch (err) {+ throw new Error(+ 'Confluence import requested but EE module not bundled in this build'+ );+ }
257-304: Unbounded Promise.all can starve the event loop and trigger BullMQ stalls on large imports. Limit concurrency.
Process pages in small batches (e.g., CPUs-1, capped at 4–8).
1-1: Confirm EE submodule bump: verify commit provenance, CI submodule update, and breaking changes.
.gitmodules: apps/server/src/ee -> https://github.com/docmost/ee. HEAD submodule commit is d03a6a3f2de77df4447b56135e1600243bd67173 (previous d90ce7a…); commits not present locally — confirm d03a6a3 is an audited/tagged EE release and contains only the intended import-task fixes (link tag/changelog/compare in the PR).
Ensure CI runs submodule sync/update so builds use the new EE commit:
git submodule sync --recursive && git submodule update --init --recursive
Prefer pinning the submodule to a tag for auditability; if no tag exists, add a PR note linking the EE changelog/compare for this range.
Sanity-check for new DB migrations or breaking API changes in EE that could affect import processors/queues.
56-57: Pass isConfluenceImport from callers (Confluence=true; others false/undefined).
processAttachments(...) is invoked at apps/server/src/integrations/import/services/file-import-task.service.ts:260 but no isConfluenceImport is passed; import-attachment.service.ts declares the param (fn signature at line 48) and early-returns when !isConfluenceImport (if (!isConfluenceImport) at line 569). Ensure the Confluence EE import path calls processAttachments with isConfluenceImport: true, and Notion/generic callers pass false or leave it undefined.
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Good call on longer indexing backoff; add an upload timeout to prevent job stalls.
Stalls are often blocked streams. Wrap uploadStream with a per‑file timeout and abort the read stream on expiry.
// Add once near other constants:privatereadonlyUPLOAD_TIMEOUT_MS=parseInt(process.env.IMPORT_UPLOAD_TIMEOUT_MS??'120000',10);// Inside uploadWithRetry() before/around uploadStream():constfileStream=createReadStream(abs);try{awaitPromise.race([this.storageService.uploadStream(storageFilePath,fileStream),newPromise((_,reject)=>setTimeout(()=>{try{fileStream.destroy(newError('upload timeout'));}catch{}reject(newError(`Upload timed out after ${this.UPLOAD_TIMEOUT_MS} ms`));},this.UPLOAD_TIMEOUT_MS),),]);}finally{// Best-effort closetry{fileStream.destroy();}catch{}}
🤖 Prompt for AI Agents
In apps/server/src/integrations/import/services/import-attachment.service.ts
around line 836, the upload can stall because uploadStream may block
indefinitely; add a per-file upload timeout to abort stalled uploads by: define
a UPLOAD_TIMEOUT_MS constant (from process.env IMPORT_UPLOAD_TIMEOUT_MS with a
sensible default like 120000), then when creating the read stream for a file
wrap the upload call in a Promise.race between storageService.uploadStream(...)
and a timeout Promise that destroys the read stream and rejects with a timeout
error after UPLOAD_TIMEOUT_MS, and finally ensure a best-effort cleanup by
destroying/closing the file stream in a finally block so stuck streams are
aborted and jobs don’t hang.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix bug which causes imports with attachments to stall and crash the server.
Closes #1550.
Summary by CodeRabbit
New Features
Improvements
Style
Chores