Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/pdf-server/src/mcp-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3875,7 +3875,11 @@ async function loadPdfProgressively(urlToLoad: string): Promise<{
requestDataRange(begin: number, end: number) {
fetchRange(urlToLoad, begin, end)
.then((result) => {
this.onDataRange(begin, result.bytes);
// PDF.js transfers the ArrayBuffer to its worker, detaching it.
// Pass a copy so the rangeCache entry stays valid for re-requests
// (iOS/WKWebView re-requests ranges under memory pressure and
// throws "Buffer is already detached" on the cached original).
this.onDataRange(begin, result.bytes.slice());
})
.catch((err: unknown) => {
log.error(`Error fetching range ${begin}-${end}:`, err);
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/pdf-annotations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function extractViewUUID(page: Page): Promise<string> {
const resultText = (await resultContent.textContent()) ?? "";

// Extract viewUUID from the JSON result
// The text content includes: "Displaying PDF (viewUUID: <uuid>): ..."
// The text content includes: "PDF opened. viewUUID: <uuid>"
const match = resultText.match(/viewUUID["\s:]+([a-f0-9-]{36})/);
if (!match) {
throw new Error(
Expand Down Expand Up @@ -107,7 +107,7 @@ test.describe("PDF Server - Annotations", () => {
// (interact action list lives in the tool description, not the runtime result).
expect(resultText).toContain("viewUUID");
expect(resultText).toContain("interactEnabled");
expect(resultText).toContain("Displaying PDF");
expect(resultText).toContain("PDF opened");
});

test("interact tool is available in tool dropdown", async ({ page }) => {
Expand Down
Loading