prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Outfile -w cannot be loaded
  #### Problem Description
  When the dump file is getting bigger, about 100mb it's not loaded anymore.
  
  #### Steps to reproduce the behavior:
  Make a big outfile and try to open it with an new instance of mitmweb.
  
  #### System Information
  Mitmweb Windows 10 6.0.2
  mitmweb Not loading my saved flow
  So I recorded some actions with mitmweb and saved the flow.
  
  Then I closed mitmweb, and reopened it.  Then I went to open the saved flow file (which is 100 megabytes).  But when I open it, the requests and responses do not appear?
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `mitmproxy/tools/web/master.py`
  Content:
  ```
  1 import errno
  2 import logging
  3 
  4 import tornado.httpserver
  5 import tornado.ioloop
  6 
  7 from mitmproxy import addons
  8 from mitmproxy import flow
  9 from mitmproxy import log
  10 from mitmproxy import master
  11 from mitmproxy import options
  12 from mitmproxy import optmanager
  13 from mitmproxy.addons import errorcheck
  14 from mitmproxy.addons import eventstore
  15 from mitmproxy.addons import intercept
  16 from mitmproxy.addons import readfile
  17 from mitmproxy.addons import termlog
  18 from mitmproxy.addons import view
  19 from mitmproxy.addons.proxyserver import Proxyserver
  20 from mitmproxy.tools.web import app
  21 from mitmproxy.tools.web import static_viewer
  22 from mitmproxy.tools.web import webaddons
  23 
  24 logger = logging.getLogger(__name__)
  25 
  26 
  27 class WebMaster(master.Master):
  28     def __init__(self, opts: options.Options, with_termlog: bool = True):
  29         super().__init__(opts)
  30         self.view = view.View()
  31         self.view.sig_view_add.connect(self._sig_view_add)
  32         self.view.sig_view_remove.connect(self._sig_view_remove)
  33         self.view.sig_view_update.connect(self._sig_view_update)
  34         self.view.sig_view_refresh.connect(self._sig_view_refresh)
  35 
  36         self.events = eventstore.EventStore()
  37         self.events.sig_add.connect(self._sig_events_add)
  38         self.events.sig_refresh.connect(self._sig_events_refresh)
  39 
  40         self.options.changed.connect(self._sig_options_update)
  41 
  42         if with_termlog:
  43             self.addons.add(termlog.TermLog())
  44         self.addons.add(*addons.default_addons())
  45         self.addons.add(
  46             webaddons.WebAddon(),
  47             intercept.Intercept(),
  48             readfile.ReadFile(),
  49             static_viewer.StaticViewer(),
  50             self.view,
  51             self.events,
  52             errorcheck.ErrorCheck(),
  53         )
  54         self.app = app.Application(self, self.options.web_debug)
  55         self.proxyserver: Proxyserver = self.addons.get("proxyserver")
  56         self.proxyserver.servers.changed.connect(self._sig_servers_changed)
  57 
  58     def _sig_view_add(self, flow: flow.Flow) -> None:
  59         app.ClientConnection.broadcast(
  60             resource="flows", cmd="add", data=app.flow_to_json(flow)
  61         )
  62 
  63     def _sig_view_update(self, flow: flow.Flow) -> None:
  64         app.ClientConnection.broadcast(
  65             resource="flows", cmd="update", data=app.flow_to_json(flow)
  66         )
  67 
  68     def _sig_view_remove(self, flow: flow.Flow, index: int) -> None:
  69         app.ClientConnection.broadcast(resource="flows", cmd="remove", data=flow.id)
  70 
  71     def _sig_view_refresh(self) -> None:
  72         app.ClientConnection.broadcast(resource="flows", cmd="reset")
  73 
  74     def _sig_events_add(self, entry: log.LogEntry) -> None:
  75         app.ClientConnection.broadcast(
  76             resource="events", cmd="add", data=app.logentry_to_json(entry)
  77         )
  78 
  79     def _sig_events_refresh(self) -> None:
  80         app.ClientConnection.broadcast(resource="events", cmd="reset")
  81 
  82     def _sig_options_update(self, updated: set[str]) -> None:
  83         options_dict = optmanager.dump_dicts(self.options, updated)
  84         app.ClientConnection.broadcast(
  85             resource="options", cmd="update", data=options_dict
  86         )
  87 
  88     def _sig_servers_changed(self) -> None:
  89         app.ClientConnection.broadcast(
  90             resource="state",
  91             cmd="update",
  92             data={"servers": [s.to_json() for s in self.proxyserver.servers]},
  93         )
  94 
  95     async def running(self):
  96         # Register tornado with the current event loop
  97         tornado.ioloop.IOLoop.current()
  98 
  99         # Add our web app.
  100         http_server = tornado.httpserver.HTTPServer(self.app)
  101         try:
  102             http_server.listen(self.options.web_port, self.options.web_host)
  103         except OSError as e:
  104             message = f"Web server failed to listen on {self.options.web_host or '*'}:{self.options.web_port} with {e}"
  105             if e.errno == errno.EADDRINUSE:
  106                 message += f"\nTry specifying a different port by using `--set web_port={self.options.web_port + 2}`."
  107             raise OSError(e.errno, message, e.filename) from e
  108 
  109         logger.info(
  110             f"Web server listening at http://{self.options.web_host}:{self.options.web_port}/",
  111         )
  112 
  113         return await super().running()
  114
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/mitmproxy/tools/web/master.py b/mitmproxy/tools/web/master.py
  --- a/mitmproxy/tools/web/master.py
  +++ b/mitmproxy/tools/web/master.py
  @@ -97,7 +97,9 @@
           tornado.ioloop.IOLoop.current()
   
           # Add our web app.
  -        http_server = tornado.httpserver.HTTPServer(self.app)
  +        http_server = tornado.httpserver.HTTPServer(
  +            self.app, max_buffer_size=2**32
  +        )  # 4GB
           try:
               http_server.listen(self.options.web_port, self.options.web_host)
           except OSError as e:
  
verification_info: {"golden_diff": "diff --git a/mitmproxy/tools/web/master.py b/mitmproxy/tools/web/master.py\n--- a/mitmproxy/tools/web/master.py\n+++ b/mitmproxy/tools/web/master.py\n@@ -97,7 +97,9 @@\n         tornado.ioloop.IOLoop.current()\n \n         # Add our web app.\n-        http_server = tornado.httpserver.HTTPServer(self.app)\n+        http_server = tornado.httpserver.HTTPServer(\n+            self.app, max_buffer_size=2**32\n+        )  # 4GB\n         try:\n             http_server.listen(self.options.web_port, self.options.web_host)\n         except OSError as e:\n", "issue": "Outfile -w cannot be loaded\n#### Problem Description\nWhen the dump file is getting bigger, about 100mb it's not loaded anymore.\n\n#### Steps to reproduce the behavior:\nMake a big outfile and try to open it with an new instance of mitmweb.\n\n#### System Information\nMitmweb Windows 10 6.0.2\nmitmweb Not loading my saved flow\nSo I recorded some actions with mitmweb and saved the flow.\r\n\r\nThen I closed mitmweb, and reopened it.  Then I went to open the saved flow file (which is 100 megabytes).  But when I open it, the requests and responses do not appear?\r\n\n", "before_files": [{"content": "import errno\nimport logging\n\nimport tornado.httpserver\nimport tornado.ioloop\n\nfrom mitmproxy import addons\nfrom mitmproxy import flow\nfrom mitmproxy import log\nfrom mitmproxy import master\nfrom mitmproxy import options\nfrom mitmproxy import optmanager\nfrom mitmproxy.addons import errorcheck\nfrom mitmproxy.addons import eventstore\nfrom mitmproxy.addons import intercept\nfrom mitmproxy.addons import readfile\nfrom mitmproxy.addons import termlog\nfrom mitmproxy.addons import view\nfrom mitmproxy.addons.proxyserver import Proxyserver\nfrom mitmproxy.tools.web import app\nfrom mitmproxy.tools.web import static_viewer\nfrom mitmproxy.tools.web import webaddons\n\nlogger = logging.getLogger(__name__)\n\n\nclass WebMaster(master.Master):\n    def __init__(self, opts: options.Options, with_termlog: bool = True):\n        super().__init__(opts)\n        self.view = view.View()\n        self.view.sig_view_add.connect(self._sig_view_add)\n        self.view.sig_view_remove.connect(self._sig_view_remove)\n        self.view.sig_view_update.connect(self._sig_view_update)\n        self.view.sig_view_refresh.connect(self._sig_view_refresh)\n\n        self.events = eventstore.EventStore()\n        self.events.sig_add.connect(self._sig_events_add)\n        self.events.sig_refresh.connect(self._sig_events_refresh)\n\n        self.options.changed.connect(self._sig_options_update)\n\n        if with_termlog:\n            self.addons.add(termlog.TermLog())\n        self.addons.add(*addons.default_addons())\n        self.addons.add(\n            webaddons.WebAddon(),\n            intercept.Intercept(),\n            readfile.ReadFile(),\n            static_viewer.StaticViewer(),\n            self.view,\n            self.events,\n            errorcheck.ErrorCheck(),\n        )\n        self.app = app.Application(self, self.options.web_debug)\n        self.proxyserver: Proxyserver = self.addons.get(\"proxyserver\")\n        self.proxyserver.servers.changed.connect(self._sig_servers_changed)\n\n    def _sig_view_add(self, flow: flow.Flow) -> None:\n        app.ClientConnection.broadcast(\n            resource=\"flows\", cmd=\"add\", data=app.flow_to_json(flow)\n        )\n\n    def _sig_view_update(self, flow: flow.Flow) -> None:\n        app.ClientConnection.broadcast(\n            resource=\"flows\", cmd=\"update\", data=app.flow_to_json(flow)\n        )\n\n    def _sig_view_remove(self, flow: flow.Flow, index: int) -> None:\n        app.ClientConnection.broadcast(resource=\"flows\", cmd=\"remove\", data=flow.id)\n\n    def _sig_view_refresh(self) -> None:\n        app.ClientConnection.broadcast(resource=\"flows\", cmd=\"reset\")\n\n    def _sig_events_add(self, entry: log.LogEntry) -> None:\n        app.ClientConnection.broadcast(\n            resource=\"events\", cmd=\"add\", data=app.logentry_to_json(entry)\n        )\n\n    def _sig_events_refresh(self) -> None:\n        app.ClientConnection.broadcast(resource=\"events\", cmd=\"reset\")\n\n    def _sig_options_update(self, updated: set[str]) -> None:\n        options_dict = optmanager.dump_dicts(self.options, updated)\n        app.ClientConnection.broadcast(\n            resource=\"options\", cmd=\"update\", data=options_dict\n        )\n\n    def _sig_servers_changed(self) -> None:\n        app.ClientConnection.broadcast(\n            resource=\"state\",\n            cmd=\"update\",\n            data={\"servers\": [s.to_json() for s in self.proxyserver.servers]},\n        )\n\n    async def running(self):\n        # Register tornado with the current event loop\n        tornado.ioloop.IOLoop.current()\n\n        # Add our web app.\n        http_server = tornado.httpserver.HTTPServer(self.app)\n        try:\n            http_server.listen(self.options.web_port, self.options.web_host)\n        except OSError as e:\n            message = f\"Web server failed to listen on {self.options.web_host or '*'}:{self.options.web_port} with {e}\"\n            if e.errno == errno.EADDRINUSE:\n                message += f\"\\nTry specifying a different port by using `--set web_port={self.options.web_port + 2}`.\"\n            raise OSError(e.errno, message, e.filename) from e\n\n        logger.info(\n            f\"Web server listening at http://{self.options.web_host}:{self.options.web_port}/\",\n        )\n\n        return await super().running()\n", "path": "mitmproxy/tools/web/master.py"}], "after_files": [{"content": "import errno\nimport logging\n\nimport tornado.httpserver\nimport tornado.ioloop\n\nfrom mitmproxy import addons\nfrom mitmproxy import flow\nfrom mitmproxy import log\nfrom mitmproxy import master\nfrom mitmproxy import options\nfrom mitmproxy import optmanager\nfrom mitmproxy.addons import errorcheck\nfrom mitmproxy.addons import eventstore\nfrom mitmproxy.addons import intercept\nfrom mitmproxy.addons import readfile\nfrom mitmproxy.addons import termlog\nfrom mitmproxy.addons import view\nfrom mitmproxy.addons.proxyserver import Proxyserver\nfrom mitmproxy.tools.web import app\nfrom mitmproxy.tools.web import static_viewer\nfrom mitmproxy.tools.web import webaddons\n\nlogger = logging.getLogger(__name__)\n\n\nclass WebMaster(master.Master):\n    def __init__(self, opts: options.Options, with_termlog: bool = True):\n        super().__init__(opts)\n        self.view = view.View()\n        self.view.sig_view_add.connect(self._sig_view_add)\n        self.view.sig_view_remove.connect(self._sig_view_remove)\n        self.view.sig_view_update.connect(self._sig_view_update)\n        self.view.sig_view_refresh.connect(self._sig_view_refresh)\n\n        self.events = eventstore.EventStore()\n        self.events.sig_add.connect(self._sig_events_add)\n        self.events.sig_refresh.connect(self._sig_events_refresh)\n\n        self.options.changed.connect(self._sig_options_update)\n\n        if with_termlog:\n            self.addons.add(termlog.TermLog())\n        self.addons.add(*addons.default_addons())\n        self.addons.add(\n            webaddons.WebAddon(),\n            intercept.Intercept(),\n            readfile.ReadFile(),\n            static_viewer.StaticViewer(),\n            self.view,\n            self.events,\n            errorcheck.ErrorCheck(),\n        )\n        self.app = app.Application(self, self.options.web_debug)\n        self.proxyserver: Proxyserver = self.addons.get(\"proxyserver\")\n        self.proxyserver.servers.changed.connect(self._sig_servers_changed)\n\n    def _sig_view_add(self, flow: flow.Flow) -> None:\n        app.ClientConnection.broadcast(\n            resource=\"flows\", cmd=\"add\", data=app.flow_to_json(flow)\n        )\n\n    def _sig_view_update(self, flow: flow.Flow) -> None:\n        app.ClientConnection.broadcast(\n            resource=\"flows\", cmd=\"update\", data=app.flow_to_json(flow)\n        )\n\n    def _sig_view_remove(self, flow: flow.Flow, index: int) -> None:\n        app.ClientConnection.broadcast(resource=\"flows\", cmd=\"remove\", data=flow.id)\n\n    def _sig_view_refresh(self) -> None:\n        app.ClientConnection.broadcast(resource=\"flows\", cmd=\"reset\")\n\n    def _sig_events_add(self, entry: log.LogEntry) -> None:\n        app.ClientConnection.broadcast(\n            resource=\"events\", cmd=\"add\", data=app.logentry_to_json(entry)\n        )\n\n    def _sig_events_refresh(self) -> None:\n        app.ClientConnection.broadcast(resource=\"events\", cmd=\"reset\")\n\n    def _sig_options_update(self, updated: set[str]) -> None:\n        options_dict = optmanager.dump_dicts(self.options, updated)\n        app.ClientConnection.broadcast(\n            resource=\"options\", cmd=\"update\", data=options_dict\n        )\n\n    def _sig_servers_changed(self) -> None:\n        app.ClientConnection.broadcast(\n            resource=\"state\",\n            cmd=\"update\",\n            data={\"servers\": [s.to_json() for s in self.proxyserver.servers]},\n        )\n\n    async def running(self):\n        # Register tornado with the current event loop\n        tornado.ioloop.IOLoop.current()\n\n        # Add our web app.\n        http_server = tornado.httpserver.HTTPServer(\n            self.app, max_buffer_size=2**32\n        )  # 4GB\n        try:\n            http_server.listen(self.options.web_port, self.options.web_host)\n        except OSError as e:\n            message = f\"Web server failed to listen on {self.options.web_host or '*'}:{self.options.web_port} with {e}\"\n            if e.errno == errno.EADDRINUSE:\n                message += f\"\\nTry specifying a different port by using `--set web_port={self.options.web_port + 2}`.\"\n            raise OSError(e.errno, message, e.filename) from e\n\n        logger.info(\n            f\"Web server listening at http://{self.options.web_host}:{self.options.web_port}/\",\n        )\n\n        return await super().running()\n", "path": "mitmproxy/tools/web/master.py"}]}