Skip to content

fix(win): lazy-load pdf-parse to avoid DOMMatrix crash at startup#10

Merged
DoyleDev merged 3 commits into
mainfrom
fix/windows-pdf-startup-crash
May 18, 2026
Merged

fix(win): lazy-load pdf-parse to avoid DOMMatrix crash at startup#10
DoyleDev merged 3 commits into
mainfrom
fix/windows-pdf-startup-crash

Conversation

@DoyleDev
Copy link
Copy Markdown
Collaborator

Summary

Windows users get `ReferenceError: DOMMatrix is not defined` on every Mason launch. pdf-parse 2.x bundles pdf.js which references DOMMatrix during module init; Electron's main-process Node exposes DOMMatrix on macOS but not Windows, so the eager `require("pdf-parse")` at the top of main.ts crashes the whole app.

This PR moves the require behind a memoized loader that runs only when a PDF upload actually fires. Mason now starts cleanly on Windows; PDF uploads on platforms where pdf-parse fails to load return a friendly error instead of crashing.

A proper PDF fix on Windows (polyfill DOMMatrix, downgrade to pdf-parse v1.x, or swap the parser) is a follow-up. This unblocks non-PDF Windows usage today.

Bumps to 1.3.13.

Test plan

  • Windows: install the new .exe, app launches without the DOMMatrix dialog
  • Windows: try to upload a PDF — get a friendly error, app keeps running
  • Windows: text + image uploads still work
  • macOS: PDF uploads still work end-to-end (regression check)

This pull request and its description were written by Isaac.

DoyleDev added 3 commits May 18, 2026 11:15
pdf-parse 2.x bundles pdf.js, which references DOMMatrix during
module init. Electron's main-process Node context exposes DOMMatrix
on macOS but not on Windows, so eagerly requiring pdf-parse at
startup crashed Mason on every Windows launch:

  ReferenceError: DOMMatrix is not defined
    at Module.<anonymous> (...resources/app.asar/node_modules/.../pdf-parse...)
    at Module._compile (...build/ts/main.js:22)

Move the require behind a memoized loader that runs only when a PDF
upload actually happens. Mason now starts cleanly on Windows; PDF
uploads on platforms where pdf-parse fails to load return a friendly
"PDF support isn't available on this build" error instead of taking
down the whole app.

A proper PDF fix on Windows (polyfill DOMMatrix, downgrade to v1.x,
or swap the parser) is a follow-up. For now the goal is to unblock
non-PDF Windows usage.

Co-authored-by: Isaac
Co-authored-by: Isaac
scripts/install.ps1: PowerShell installer analogous to install.sh on
macOS. Auto-detects x64 vs ARM64, queries the latest GitHub release,
downloads the matching "Mason Setup X.Y.Z(-arm64).exe", and runs it
silently as a per-user install (no admin elevation). Launches Mason
on success. MASON_VERSION env var pins to a specific tag.

README: Windows section with the irm | iex one-liner, manual-install
guidance with arch selection, and a note for Linux build-from-source.

Also gitignores the local Makefile alongside other dev-only files.

Co-authored-by: Isaac
@DoyleDev DoyleDev merged commit 3b754d8 into main May 18, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant