Skip to content

Windows: fix installer crash (electron-builder bump), memry-file paths, and cloud-lock write retries#736

Merged
h4yfans merged 4 commits into
mainfrom
fix/windows-installer-and-memry-file
Jul 10, 2026
Merged

Windows: fix installer crash (electron-builder bump), memry-file paths, and cloud-lock write retries#736
h4yfans merged 4 commits into
mainfrom
fix/windows-installer-and-memry-file

Conversation

@h4yfans

@h4yfans h4yfans commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Why

A Windows user (Reddit r/MemryNote) hit three independent failures, all confirmed from his main.log + Event Viewer data:

  1. MemryNote-*-setup.exe crashes before showing any UI — faulting module System.dll (NSIS plugin), 0xc0000005 at offset 0x1581, 3× deterministic. Root cause is a buffer over-read in electron-builder 26.7.0's stock multiUser.nsh per-user fresh-install branch (System::Call '*$2(&w${NSIS_MAX_STRLEN} .s)' reading a small SHGetKnownFolderPath buffer), fixed upstream in 26.9.0+. It only fires when no HKCU InstallLocation exists — which is why updates worked for years but a clean install after uninstall dies instantly, and why his in-app update "got stuck" (the app quit cleanly; the silent NSIS run crashed after exit).
  2. Every PDF/image opened from Collections shows "server error" on Windows — two stacked path bugs: renderer built memry-file://local${absolutePath}, so C: was parsed as the URL host and the handler resolved a relative path against the install dir; and the handler allowlist compared with startsWith(dir + '/'), which never matches Windows backslash paths, so even a well-formed URL was 403'd. His log shows the exact mangled path (...\Programs\@memrydesktop\Users\Leib.000\Koofr\...).
  3. Clicking an attachment link inside a note did nothingmemry-file: fell into the openExternal scheme allowlist and was silently denied (8× in his log).

His vault also lives inside a Koofr cloud-sync folder, which holds transient locks on vault files.

What

  • Bump electron-builder ^26.0.12^26.15.6 — the fixed template uses a bounded lstrcpynW copy. Verified by cross-building the actual Windows targets on macOS with the new version: real MemryNote-*-setup.exe (146 MB) + MemryNote-*-win.zip (191 MB) produced.
  • Publish a MemryNote-<version>-win.zip alongside the setup exe (installer-free escape hatch for support). latest.yml still lists only the setup exe, so electron-updater behavior is unchanged; landing download API keeps resolving -setup.exe (fixture test with the zip listed first).
  • toMemryFileUrl renderer helper (leading slash, backslash→slash, per-segment percent-encoding) replacing both string-concat build sites; round-trip tests for Windows drive paths, spaces, Hebrew filenames, and URL-hostile chars.
  • isPathInsideDirs platform-separator containment used by the protocol handler and the window-open route; win32 behavior unit-tested (prefix-sibling dirs rejected).
  • memry-file window opens route to shell.openPath after the same containment check, never shell.openExternal; unknown schemes still blocked, https still allowed (tests extended).
  • Atomic vault writes retry EBUSY/EPERM/EACCES with bounded backoff (~3 attempts, <1s total) for cloud-sync/AV locks; tests cover transient-then-success, persistent failure, and immediate ENOENT propagation.
  • Startup log line with app version + channel — his log's binary change was only detectable via an unrelated log-text diff.
  • Docs: memry-file path rules + retry semantics in architecture/local-storage.md, zip fallback in guide/install.md.

Proof

  • Focused + full suites green locally: main 3487 / renderer 5096 / shared 2074 passed; lint 0 errors; typecheck 16/16 tasks; docs:impact --strict + docs:build green.
  • New tests: memry-file-url.test.ts (8), external-url.test.ts (+10 incl. 5 win32 containment), index.phase2.test.ts (+2 wiring), file-ops.test.ts (retry matrix), apps/landing/api/download.test.ts (zip fixture).
  • Local electron-builder 26.15.6 Windows build artifacts produced end-to-end (unsigned, version-unstamped — CI holds secrets/version).

Notes

h4yfans added 4 commits July 10, 2026 15:27
- Build memry-file URLs through a shared toMemryFileUrl helper: guaranteed
  leading slash, backslash-to-slash, per-segment percent-encoding, so
  Windows drive-letter paths no longer land in the URL host and resolve
  against the install directory (403 'server error' on every PDF/image).
- Protocol handler allowlist now compares with the platform separator
  (isPathInsideDirs); the old dir + '/' prefix never matched Windows
  backslash paths, so even well-formed URLs were blocked.
- Clicking a memry-file attachment link inside a note now opens the file
  via shell.openPath (vault/userData containment enforced) instead of
  being silently dropped by the openExternal allowlist.
- Log app version and channel at startup for support triage.
Cloud-sync clients (Koofr/OneDrive/Dropbox) and antivirus scanners hold
short-lived locks on vault files; atomic-write renames now retry
EBUSY/EPERM/EACCES with bounded backoff instead of failing the save.
electron-builder 26.7.0's stock NSIS multiUser.nsh has a System.dll
buffer over-read in the per-user fresh-install branch (crashes 0xc0000005
in .onInit — installer dies before any UI on affected machines; fixed
upstream in 26.9.0, hardened later). 26.15.6 templates use a bounded
lstrcpynW copy instead.

Also publish MemryNote-<version>-win.zip alongside the setup exe so
support can hand out an installer-free build; latest.yml still lists
only the setup exe, so auto-update behavior is unchanged. Landing
download API keeps resolving the -setup.exe (fixture test added).
@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
memry-docs Ready Ready Preview, Comment Jul 10, 2026 12:44pm
memrynote-landing Ready Ready Preview, Comment Jul 10, 2026 12:44pm

@github-actions github-actions Bot added bug Something isn't working dependencies documentation Improvements or additions to documentation test labels Jul 10, 2026
@github-actions

Copy link
Copy Markdown

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit 655dc9b.

// Write to the uniquely-named temp file exclusively (wx) with owner-only
// permissions, so a pre-existing symlink in a shared directory can't be
// followed and the temp contents can't be read by other users.
await writeFile(tempPath, content, { encoding: 'utf-8', mode: 0o600, flag: 'wx' })
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.54930% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
apps/desktop/src/main/sync/attachments.ts 64.28% 5 Missing ⚠️
apps/desktop/src/main/lib/external-url.ts 94.73% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@h4yfans h4yfans marked this pull request as ready for review July 10, 2026 13:01
@h4yfans h4yfans merged commit bdaf4cb into main Jul 10, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working dependencies documentation Improvements or additions to documentation test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants