Tencent/WeKnora · error

MinerU Cloud poll: %w

Error message

MinerU Cloud poll: %w

What it means

Once uploaded, Read polls pollBatchResult until MinerU finishes converting the batch; any failure or terminal error state is wrapped as "MinerU Cloud poll: %w". This covers both transport errors while polling and the job ending in a failed/expired state.

Source

Thrown at internal/infrastructure/docparser/mineru_cloud_converter.go:90

		ext = ".pdf"
	}
	fileName := strings.TrimSuffix(req.FileName, ext) + ext
	if fileName == ext {
		fileName = "document" + ext
	}

	batchID, uploadURL, err := c.applyUploadURLs(ctx, fileName, ext)
	if err != nil {
		return nil, fmt.Errorf("MinerU Cloud apply upload URLs: %w", err)
	}

	if err := c.uploadFile(ctx, uploadURL, content); err != nil {
		return nil, fmt.Errorf("MinerU Cloud file upload: %w", err)
	}

	mdContent, imageRefs, err := c.pollBatchResult(ctx, batchID)
	if err != nil {
		return nil, fmt.Errorf("MinerU Cloud poll: %w", err)
	}

	mdContent, imageRefs = ensureOriginalImageRef(req, mdContent, imageRefs)

	return &types.ReadResult{
		MarkdownContent: mdContent,
		ImageRefs:       imageRefs,
	}, nil
}

// --- batch upload API ---

type batchApplyResponse struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data struct {
		BatchID  string   `json:"batch_id"`
		FileURLs []string `json:"file_urls"`

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Inspect the wrapped cause: if the job state is 'failed', check the MinerU dashboard/logs for the document-level error (often an unsupported or corrupted file).
  2. Increase the context timeout so large documents have time to convert before polling gives up.
  3. Validate the input document opens correctly locally (not corrupt/encrypted PDF).
  4. Retry Read on transient 5xx/network errors during polling.
  5. Retry with a smaller document if conversions consistently time out.

Example fix

// before: too-short timeout kills long conversions
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
// after: allow several minutes for cloud conversion
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
Defensive patterns

Strategy: retry

Validate before calling

if encryptedOrCorruptPDF(path) { // e.g. try opening with a PDF lib
    return fmt.Errorf("%s is corrupt/encrypted; MinerU conversion will fail", path)
}
ctx, cancel := context.WithTimeout(ctx, 10*time.Minute) // allow long conversions
defer cancel()

Try / catch

res, err := converter.Read(ctx, req)
if err != nil {
    if strings.Contains(err.Error(), "MinerU Cloud poll") {
        if errors.Is(ctx.Err(), context.DeadlineExceeded) {
            return fmt.Errorf("conversion timed out; increase context timeout or split the document")
        }
        return retryWithBackoff(ctx, 2, func() error { return readAgain(ctx, req) })
    }
    return err
}

Prevention

When it happens

Trigger: Read -> pollBatchResult returned an error: polling HTTP request failed, context deadline exceeded while waiting, or the batch reached a failed/unknown state instead of producing markdown.

Common situations: Conversion job failed server-side (unsupported/corrupt document); context timeout shorter than conversion duration for big PDFs; MinerU service degraded during polling; batch ID invalid or job expired before completion.

Related errors


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/cf4556b64c9fa827. Report an issue: GitHub.