diff --git a/CHANGELOG b/CHANGELOG index 78dd1788c..7644ec8ab 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) * --- TODO: add new PRs above this line --- diff --git a/mitmproxy/tools/console/master.py b/mitmproxy/tools/console/master.py index 6ab9ba5a2..ab1d84142 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) + # small delay before removing the file + t = threading.Timer(1.0, os.unlink, args=[name]) + t.start() def set_palette(self, opts, updated): self.ui.register_palette(