Skip to content

Commit 063e962

Browse files
iYassrclaude
andcommitted
Fix PDF worker error in packaged Electron apps
The error was: "No GlobalWorkerOptions.workerSrc specified" Fix: - Set workerSrc to 'data:,' (empty data URI) instead of '' - Add disableAutoFetch and disableStream options This satisfies pdfjs's worker requirement check while running in fake worker mode for Electron compatibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 4e33b26 commit 063e962

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

electron/services/document-parser.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,17 +364,19 @@ async function parsePdf(buffer: Buffer): Promise<ParsedDocument> {
364364

365365
// Disable worker for Electron/Node.js compatibility
366366
// Workers don't work properly in packaged Electron apps
367+
// Setting workerSrc to empty string and using disableWorker option
367368
if (typeof pdfjsLib.GlobalWorkerOptions !== 'undefined') {
368-
pdfjsLib.GlobalWorkerOptions.workerSrc = ''
369-
logDebug('PDF worker disabled for Electron compatibility')
369+
// Point to a fake/empty worker to satisfy the check
370+
pdfjsLib.GlobalWorkerOptions.workerSrc = 'data:,'
371+
logDebug('PDF workerSrc set to empty data URI')
370372
}
371373

372374
// Convert Buffer to Uint8Array for pdfjs
373375
const uint8Array = new Uint8Array(buffer)
374376
logDebug('Buffer converted to Uint8Array', { length: uint8Array.length })
375377

376-
// Load the PDF document with worker disabled
377-
logDebug('Loading PDF document with pdfjs')
378+
// Load the PDF document with worker explicitly disabled
379+
logDebug('Loading PDF document with pdfjs (worker disabled)')
378380
let loadingTask
379381
try {
380382
loadingTask = pdfjsLib.getDocument({
@@ -383,6 +385,8 @@ async function parsePdf(buffer: Buffer): Promise<ParsedDocument> {
383385
disableFontFace: true,
384386
isEvalSupported: false,
385387
useWorkerFetch: false,
388+
disableAutoFetch: true,
389+
disableStream: true,
386390
verbosity: 0, // Suppress console warnings
387391
})
388392
logDebug('getDocument called, waiting for promise')

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "maskr",
3-
"version": "1.3.13",
3+
"version": "1.3.14",
44
"description": "A privacy-focused desktop app for detecting and masking sensitive information in documents before sharing with AI or other parties",
55
"main": "dist-electron/main.js",
66
"type": "module",

0 commit comments

Comments
 (0)