Skip to content

Fix/project over network fs - #4789

Closed
jyte wants to merge 7 commits into
marktext:developfrom
jyte:fix/project-over-network-fs
Closed

jyte wants to merge 7 commits into
marktext:developfrom
jyte:fix/project-over-network-fs

Conversation

@jyte

@jyte jyte commented Jun 29, 2026

Copy link
Copy Markdown

Based of PR 4788

Closes #4599 #4477 #4563 (usecase 1 & 2)

Summary

Fix file watching and image URL resolution on Windows network shares (UNC paths),
WSL, SSHFS, and other FUSE-based filesystem mounts where native file watching is
not supported and file:// URLs were malformed.

Type of change

  • Bug fix (non-breaking, fixes an issue)
  • New feature (non-breaking, adds functionality)
  • Breaking change (causes existing functionality to change)
  • Documentation update

Test plan

  • New tests added (or explain why not needed)
  • Manually tested on: Windows 11

Notes for reviewers [optional]

chokidar / fs.watch cannot watch Windows UNC paths or virtual filesystems
such as WSL2's 9P protocol, SSHFS mounts, network drives, and Docker-mounted
volumes because they do not support ReadDirectoryChangesW or inotify.

Fix: When fs.realpathSync.native() fails (indicating a non-native
filesystem), the watcher falls back to a manual readdir-based poll loop
(interval: 3s) instead of crashing or silently missing changes.

This is not ideal, but at least it works.


By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

jyte added 6 commits June 29, 2026 13:09
When a document is opened from a UNC path (e.g. \server\share\... or
\wsl.localhost\Distro\...), getImageSrc() and resolveLocalImageSrc()
produced invalid file:// URLs with 4 slashes (file:////server/share/...)
that Chromium cannot load, causing 'Load image failed' errors.

Root cause: both muya's path resolver and the desktop's export/print
resolver prepend 'file://' to UNC paths, producing the malformed URL
'file:////server/share/...' instead of the correct authority-based form
'file://server/share/...'.

Fix: add a pathToFileUrl() helper that detects UNC paths (starting with
// after backslash normalisation) and produces the correct authority form.
Applied consistently in:
- packages/muya/src/utils/image.ts: getImageSrc() and correctImageSrc()
- packages/desktop/src/renderer/src/util/resolveImageSrc.ts

Fixes marktext#4577, marktext#4563 (use case 1)
- Add pathToFileUrl helper for correct file:// URL normalization
- Switch to template literals (prefer-template lint)
- Add readdir-based polling fallback for FUSE/SSHFS watcher
- Update test expectations for normalized file:// URLs
@jyte
jyte marked this pull request as draft June 29, 2026 15:53
@jyte
jyte force-pushed the fix/project-over-network-fs branch from 446f6d1 to 144b416 Compare June 30, 2026 06:21
ced is a native module compiled for Electron's Node.js ABI. When vitest
runs under the system Node.js (CI), binding resolution hangs for >5s,
causing the dynamic import of watcher.ts to time out.

Mock ced so the import succeeds instantly and the 8 watcher tests pass.
@jyte
jyte marked this pull request as ready for review June 30, 2026 06:43
niyo-oyin added a commit to niyo-oyin/marktext-ja that referenced this pull request Jul 30, 2026
chokidar's native watchers never fire on UNC shares, WSL mounts and SSHFS,
so externally-edited files silently stayed stale. Fall back to a 3s polling
scan for those paths, and route the polled events through the same
self-write suppression the native watcher uses so saving from MarkText
itself does not raise a bogus "file changed on disk" prompt.
@Jocs Jocs closed this Sep 22, 2026
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.

[Bug] Marktext on Windows 11 does not work with a folder mounted with SSHFS

2 participants