bottle: strange bug: first request after launching the browser is skipped - (pending) request

Platform: Windows 10 Enterprise, build 19041 ; Python 3.8 ; Bottle v.0.12.19 Tested browsers: Chrome, Edge No internet connection on the computer

Run this app.py in a console:

from bottle import Bottle, TEMPLATE_PATH, template, static_file
app = Bottle("")
TEMPLATE_PATH.append("templates")
@app.route("/pages/<page>")
def page_route(page=None):
    return template(f"{page}.html")
app.run(port=5001)

templates/starting.html

hello
  • Then open Edge or Chrome, enter http://127.0.0.1:5001/pages/starting in the URL bar, then enter. Then the circular progress bar is turning, but the request isn’t done.
  • It is not logged in the Python/bottle console (which usually logs all requests)
  • The browser Developer Tools > Network tab shows Status (pending)
  • If I refresh the browser by selecting the URL bar and re-do ENTER, then it works, the request is done, and the browser shows “hello”.
  • Same problem if I launch the browser from command-line: chrome.exe --kiosk http://127.0.0.1:5001/pages/starting, sometimes it works, sometimes this page is not loaded on startup
  • This issue never happens when I use python -m http.server, so it might potentially be linked to bottle
  • I cannot reproduce the bug on another Windows 7 computer

Do you have any idea?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 27 (9 by maintainers)

Most upvoted comments

I am observing a similar issue with a “(pending)” request that doesn’t get logged and doesn’t complete until much later with a Bottle server running on Linux and recent Chrome on Mac OS.

tcpdump shows the HTTP request packet being sent by the browser to the Bottle server and ACK’d. However Bottle doesn’t seem to notice that it has a request pending: it does not log the request and it does not send any response.

Subsequently upon receiving another HTTP request, Bottle will finally notice that it already had one pending and it processes both requests immediately.

I suspect that there’s an issue in Bottle’s event loop that’s causing it to fail to notice that there’s data available to read on the socket.

In my tests, I can reproduce this very reliably by issuing POST requests from the browser by clicking on a button a few times. The requests will be processed normally several times, then one stalls.