Skip to content

Failure when uploading clipboard images with PicGo #3360

Closed

Description

@Jakentop

Description

Uploading clipboard images with PicGo fails, but if local images are uploaded via PicGo, it works

Steps to reproduce

image
When I paste an image directly from the clipboard, it stays in the Loading state
image
PicGo is configured without problems

Versions

  • MarkText version: v0.17.1
  • PicGo: 1.5.0-alpha.0
  • Operating system: windows 10

Activity

  1. Jakentop commented on Jul 21, 2022

    @Jakentop
    Author

    image
    In DevTools I found the following exception

  2. chinayangxiaowei commented on Jul 22, 2022

    @chinayangxiaowei

    You can refer to this question #3118

  3. Jakentop commented on Jul 27, 2022

    @Jakentop
    Author

    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.

  4. CarryWll commented on Aug 4, 2022

    @CarryWll

    The current installed version v0.17.1 still has this problem. Will it be fixed in the next version?

  5. Jakentop commented on Aug 5, 2022

    @Jakentop
    Author

    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.

  6. beierzhijin commented on Sep 22, 2022

    @beierzhijin

    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,作者还没发修复版,我是不是要自己打包,有什么好的方法的吗,新手求教

  7. Jakentop commented on Sep 22, 2022

    @Jakentop
    Author

    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,作者还没发修复版,我是不是要自己打包,有什么好的方法的吗,新手求教

    可以直接自己打包,其实就改了一行代码。

  8. beierzhijin commented on Sep 22, 2022

    @beierzhijin

    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

  9. kyuuketsu commented on Feb 12, 2023

    @kyuuketsu

    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

    感谢,替换原文件后终于可以正常使用图片粘贴功能了。

  10. maxchiron commented on Apr 29, 2023

    @maxchiron

    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

    You are a life saver, true LeiFeng, real man. God bless you. Thanks!

  11. elfzweik commented on May 10, 2025

    @elfzweik

    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

    @beierzhijin The fork is missing. If possible, could you republish the package?

  12. added
    🐛 bug
    🪲 pri/major
    on May 16, 2026
  13. Jocs commented on Sep 22, 2026

    @Jocs
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🪲 pri/major🐛 bug🔭 area/editor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions