Skip to content

Preserve PDF cancellation during page lookup and cleanup #531

Closed

Description

@sylvesterkaczmarek

Summary

PDF knowledge-base extraction now receives the cancellation signal, but two edge cases remain: cancellation during page lookup can still start text extraction, and a cleanup error can replace the caller's abort reason.

What is fixed

#1529 propagated the signal into PDF extraction and added checks after document loading and between page operations. The original claim that the signal never reaches extractPdf() is no longer current.

Remaining cases

Cancellation while getPage() is pending

If the caller aborts after the loop's initial check but before getPage() resolves, the current extraction loop proceeds to getTextContent() before checking again. Work can start after cancellation is already known.

Expected: check the signal after page lookup and before starting text extraction.

Cleanup replaces the abort reason

The finally block awaits loadingTask.destroy(). If extraction has already thrown the caller's abort reason and destroy() also rejects, the cleanup error replaces the original cancellation.

Expected: attempt cleanup while preserving the caller's cancellation reason. Cleanup errors outside a cancellation still need their normal handling.

Validation

Use controlled PDF-loader promises to abort during page lookup and assert that text extraction never starts. Separately make cleanup reject after an abort and assert that the caller receives the original abort reason.

#532 remains open and addresses both cases. The 17 October follow-up reproduced these gaps after the initial signal-propagation fix.

Activity

  1. mldangelo-oai commented on Oct 8, 2026

    @mldangelo-oai
    Collaborator

    #939 and #1103 also pass cancellation through PDF extraction and check it between pages. Both are still open.

  2. added
    area:knowledgeKnowledge-base documents, attachments, extraction, and prompt context.
    bugSomething isn't working
    on Oct 8, 2026
  3. mldangelo-oai commented on Oct 17, 2026

    @mldangelo-oai
    Collaborator

    #1529 addressed the basic cancellation case, but I reproduced two remaining gaps: cancellation during page lookup still starts text extraction, and a cleanup error can replace the cancellation reason. Keeping this open for #532, which fixes both.

  4. changed the title [-]Knowledge-base cancellation is ignored once PDF extraction starts[/-] [+]Preserve PDF cancellation during page lookup and cleanup[/+] on Oct 19, 2026
  5. added
    priority:p3Lower-impact improvement, documentation, or routine maintenance
    on Oct 25, 2026
  6. mldangelo-oai commented on Oct 25, 2026

    @mldangelo-oai
    Collaborator

    I reproduced this on main. Canceling during page lookup still started text extraction, and a cleanup failure could hide the reason the caller canceled. I also found that canceling while a blank PDF finished closing could surface a misleading “no extractable text” error.

    I updated #532 to cover that last case too. The tests now check all three through both SDK entry points, along with what happens when cleanup fails without a cancellation.

    The focused cases passed on Linux and Windows. I also ran the full SDK suite twice on Linux. Both runs passed 7,183 tests, with 108 skipped and no failures.

  7. added a commit that references this issue on Oct 26, 2026
    6bee354
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:knowledgeKnowledge-base documents, attachments, extraction, and prompt context.bugSomething isn't workingpriority:p3Lower-impact improvement, documentation, or routine maintenance

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions