diff --git a/CHANGELOG b/CHANGELOG index 76e27ef9b..874ed4b40 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ Unreleased: mitmproxy next * Revamp onboarding app (@mhils) * Add ASGI support for embedded apps (@mhils) * Updated raw exports to not remove headers (@wchasekelley) + * Fix file unlinking before external viewer finishes loading (@wchasekelley) * Add --cert-passphrase command line argument (@mirosyn) * --- TODO: add new PRs above this line --- diff --git a/mitmproxy/tools/console/master.py b/mitmproxy/tools/console/master.py index 6ab9ba5a2..940f379fd 100644 --- a/mitmproxy/tools/console/master.py +++ b/mitmproxy/tools/console/master.py @@ -11,6 +11,7 @@ import sys import tempfile import typing # noqa import contextlib +import threading import urwid @@ -171,7 +172,9 @@ class ConsoleMaster(master.Master): signals.status_message.send( message="Can't start external viewer: %s" % " ".join(c) ) - os.unlink(name) + # add a small delay before deletion so that the file is not removed before being loaded by the viewer + t = threading.Timer(1.0, os.unlink, args=[name]) + t.start() def set_palette(self, opts, updated): self.ui.register_palette(