You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Failure when uploading clipboard images with PicGo #3360
🪲 pri/majorBugs will affect your normal use of Mark Text, causing you unwilling or unable to continue using MT🐛 bugSomething isn't working🔭 area/editor
I found someone else had the same problem as me in #2915,I referenced his PR with #3296 but it doesn't work。I found that he reads the path information of the clipboard file, but after debug I found that in some cases (images saved in the clipboard using the screenshot tool) he has an empty path field. So one solution could be to use the MIME-TYPE in the clipboard to determine this. But I didn't want to bother with that, so I just added a fixed suffix to the filepath, and I actually found that it worked.
The current installed version v0.17.1 still has this problem. Will it be fixed in the next version?
You can find this PR, just modify a line of code to temporarily solve the problem, the specific can wait for the author to fix. #3366
You can also refer to this author's PR, #3296. I found this fix to be ineffective in my scenario for the reasons I explained above.
The current installed version v0.17.1 still has this problem. Will it be fixed in the next version?
You can find this PR, just modify a line of code to temporarily solve the problem, the specific can wait for the author to fix. #3366
You can also refer to this author's PR, #3296. I found this fix to be ineffective in my scenario for the reasons I explained above.
I want to use this fixed version, do I need to build by myself ?
我要用这个修复的pr,作者还没发修复版,我是不是要自己打包,有什么好的方法的吗,新手求教
The current installed version v0.17.1 still has this problem. Will it be fixed in the next version?
You can find this PR, just modify a line of code to temporarily solve the problem, the specific can wait for the author to fix. #3366
You can also refer to this author's PR, #3296. I found this fix to be ineffective in my scenario for the reasons I explained above.
I want to use this fixed version, do I need to build by myself ? 我要用这个修复的pr,作者还没发修复版,我是不是要自己打包,有什么好的方法的吗,新手求教
Thanks for the careful root-cause work on this thread — and sorry it sat so long.
Status: fixed. The first release carrying the fix is v0.19.0.
The helper you both dug into, src/renderer/util/fileSystem.js, no longer exists. Image upload moved into the main process (packages/desktop/src/main/ipc/uploader.ts) when the IPC/IO layer was ported and the renderer was sandboxed, and both defects you identified are gone there:
the temp path is a string now. path.join(tmpdir(), +new Date()) — a number, which throws ERR_INVALID_ARG_TYPE inside a promise nobody awaited — became String(new Date().getTime()) in fix issue 3268 #3269 (9309888b), and reads path.join(dir, `${Date.now()}${suffix}`) today. That swallowed throw is exactly why it sat on "Loading" forever, and why only clipboard images failed while local images uploaded fine, as @Jakentop noted;
the extension is appended (suffix = path.extname(name || ''), 624e69cb), so a pasted screenshot reaches PicGo as <timestamp>.png and it can infer the type — the second half of what @Jakentop found, and the same thing his one-line workaround did.
git tag --contains puts both commits first in v0.19.0 (current stable is v0.19.1; v0.20.0-rc.5 is the newest pre-release). You should no longer need the patched 0.17.1 builds people rebuilt from this thread.
What we actually ran, rather than just reading the diff: a real build, a real bitmap on the system clipboard, a real paste into the editor with Image insert action = upload and PicGo selected. The picgo binary was shadowed by a stand-in so nothing was uploaded anywhere; it recorded being invoked as u /var/folders/…/marktext-upload-XXXXXX/<timestamp>.png — a real, non-empty file, with .png on it — and the document held the returned URL about a second later. No spinner, no warning, no silent fallback to a local copy.
To make sure that check could actually fail, we put each old defect back in turn: with the number-as-path, PicGo is never invoked at all; with the extension dropped, the temp file loses .png; and with a PicGo that never exits, the placeholder stays on the spinner. So the green result is not vacuous.
What we did not verify: this was run on macOS, and this was reported on Windows 10. Windows takes a slightly different branch (PicGo is started through a shell there, because picgo is a .cmd shim). We have no reason to think it is broken, but we did not run it.
One honest caveat about the symptom. The defect reported here is gone, but "stuck on Loading" is still reachable from outside the app: MarkText runs picgo u <file> with no timeout, and nothing clears the loading placeholder on failure. So if the PicGo CLI itself never returns — for example its upload to the image host stalls on a blocked connection — MarkText waits indefinitely, with no error and no way to cancel. We reproduced that deliberately with a PicGo that never exits. It is a different bug from this one, with a different trigger (it would affect local-file uploads too, which is the opposite of what was reported here), and it should be tracked separately.
Two things worth checking if you try again and it still does not work:
MarkText shells out to the PicGo CLI (picgo-core, npm i -g picgo), not the PicGo desktop app. Confirm picgo u some.png works in a terminal first.
If MarkText cannot find picgo on PATH it does not hang — you get an "Upload Image" warning and the image is copied into the local assets folder instead. Note that a GUI-launched app does not inherit your shell's PATH, so a picgo installed under pnpm or nvm may not be found even though it works in a terminal.
Closing as fixed. If a clipboard paste with PicGo still fails for you on v0.19.1 or v0.20.0-rc.5, please comment here or open a new issue with your OS, how PicGo was installed, and what the placeholder does (stuck spinner vs. warning toast vs. local copy) — we will reopen and dig in.
🪲 pri/majorBugs will affect your normal use of Mark Text, causing you unwilling or unable to continue using MT🐛 bugSomething isn't working🔭 area/editor
Activity
Jakentop commentedon Jul 21, 2022
In DevTools I found the following exception
chinayangxiaowei commentedon Jul 22, 2022
You can refer to this question #3118
Jakentop commentedon Jul 27, 2022
I found someone else had the same problem as me in #2915,I referenced his PR with #3296 but it doesn't work。I found that he reads the path information of the clipboard file, but after debug I found that in some cases (images saved in the clipboard using the screenshot tool) he has an empty path field. So one solution could be to use the MIME-TYPE in the clipboard to determine this. But I didn't want to bother with that, so I just added a fixed suffix to the filepath, and I actually found that it worked.
fix Failure when uploading clipboard images with PicGo marktext#3360
fix Failure when uploading clipboard images with PicGo marktext#3360
CarryWll commentedon Aug 4, 2022
The current installed version v0.17.1 still has this problem. Will it be fixed in the next version?
Jakentop commentedon Aug 5, 2022
beierzhijin commentedon Sep 22, 2022
I want to use this fixed version, do I need to build by myself ?
我要用这个修复的pr,作者还没发修复版,我是不是要自己打包,有什么好的方法的吗,新手求教
Jakentop commentedon Sep 22, 2022
可以直接自己打包,其实就改了一行代码。
beierzhijin commentedon Sep 22, 2022
I have rebuilt the fixed version from @Jakentop-fix Failure when uploading clipboard images with PicGo #3360. 栓Q@Jakentop.
download from my fork: https://github.com/beierzhijin/marktext/releases/tag/v0.17.1
kyuuketsu commentedon Feb 12, 2023
感谢,替换原文件后终于可以正常使用图片粘贴功能了。
maxchiron commentedon Apr 29, 2023
You are a life saver, true LeiFeng, real man. God bless you. Thanks!
elfzweik commentedon May 10, 2025
@beierzhijin The fork is missing. If possible, could you republish the package?
Jocs commentedon Sep 22, 2026
Thanks for the careful root-cause work on this thread — and sorry it sat so long.
Status: fixed. The first release carrying the fix is v0.19.0.
The helper you both dug into,
src/renderer/util/fileSystem.js, no longer exists. Image upload moved into the main process (packages/desktop/src/main/ipc/uploader.ts) when the IPC/IO layer was ported and the renderer was sandboxed, and both defects you identified are gone there:path.join(tmpdir(), +new Date())— a number, which throwsERR_INVALID_ARG_TYPEinside a promise nobody awaited — becameString(new Date().getTime())in fix issue 3268 #3269 (9309888b), and readspath.join(dir, `${Date.now()}${suffix}`)today. That swallowed throw is exactly why it sat on "Loading" forever, and why only clipboard images failed while local images uploaded fine, as @Jakentop noted;suffix = path.extname(name || ''),624e69cb), so a pasted screenshot reaches PicGo as<timestamp>.pngand it can infer the type — the second half of what @Jakentop found, and the same thing his one-line workaround did.git tag --containsputs both commits first in v0.19.0 (current stable is v0.19.1; v0.20.0-rc.5 is the newest pre-release). You should no longer need the patched 0.17.1 builds people rebuilt from this thread.What we actually ran, rather than just reading the diff: a real build, a real bitmap on the system clipboard, a real paste into the editor with Image insert action = upload and PicGo selected. The
picgobinary was shadowed by a stand-in so nothing was uploaded anywhere; it recorded being invoked asu /var/folders/…/marktext-upload-XXXXXX/<timestamp>.png— a real, non-empty file, with.pngon it — and the document held the returned URL about a second later. No spinner, no warning, no silent fallback to a local copy.To make sure that check could actually fail, we put each old defect back in turn: with the number-as-path, PicGo is never invoked at all; with the extension dropped, the temp file loses
.png; and with a PicGo that never exits, the placeholder stays on the spinner. So the green result is not vacuous.What we did not verify: this was run on macOS, and this was reported on Windows 10. Windows takes a slightly different branch (PicGo is started through a shell there, because
picgois a.cmdshim). We have no reason to think it is broken, but we did not run it.One honest caveat about the symptom. The defect reported here is gone, but "stuck on Loading" is still reachable from outside the app: MarkText runs
picgo u <file>with no timeout, and nothing clears the loading placeholder on failure. So if the PicGo CLI itself never returns — for example its upload to the image host stalls on a blocked connection — MarkText waits indefinitely, with no error and no way to cancel. We reproduced that deliberately with a PicGo that never exits. It is a different bug from this one, with a different trigger (it would affect local-file uploads too, which is the opposite of what was reported here), and it should be tracked separately.Two things worth checking if you try again and it still does not work:
npm i -g picgo), not the PicGo desktop app. Confirmpicgo u some.pngworks in a terminal first.picgoonPATHit does not hang — you get an "Upload Image" warning and the image is copied into the local assets folder instead. Note that a GUI-launched app does not inherit your shell'sPATH, so apicgoinstalled under pnpm or nvm may not be found even though it works in a terminal.Closing as fixed. If a clipboard paste with PicGo still fails for you on v0.19.1 or v0.20.0-rc.5, please comment here or open a new issue with your OS, how PicGo was installed, and what the placeholder does (stuck spinner vs. warning toast vs. local copy) — we will reopen and dig in.
fix(desktop): stop clipboard image uploads clobbering each other and …