ValueError: "Session 12345 executing periodic callback '_reload_on_update' (216)" is not in list when using the admin panel

I’m trying to profile my application for bottlenecks. I enabled the admin panel but as soon as I enter it (http://localhost:5006/admin), I start getting exceptions in the console, which persist even if I close the admin panel.

The environment

Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
Panel: 1.3.6
Bokeh: 3.2.2
Param: 2.0.2

MWE

import panel as pn
import hvplot.pandas
import pandas as pd
import numpy as np

pn.extension(design="material")


@pn.cache()
def get_data():
    csv_file = "https://raw.githubusercontent.com/holoviz/panel/main/examples/assets/occupancy.csv"
    return pd.read_csv(csv_file, parse_dates=["date"], index_col="date")


data = get_data()


def transform_data(variable, window, sigma):
    """Calculates the rolling average and the outliers"""
    avg = data[variable].rolling(window=window).mean()
    residual = data[variable] - avg
    std = residual.rolling(window=window).std()
    outliers = np.abs(residual) > std * sigma
    return avg, avg[outliers]


def create_plot(variable="Temperature", window=30, sigma=10):
    """Plots the rolling average and the outliers"""
    avg, highlight = transform_data(variable, window, sigma)
    return avg.hvplot(height=300, width=400, legend=False) * highlight.hvplot.scatter(
        color="orange", padding=0.1, legend=False
    )


plot = create_plot(variable="Temperature", window=20, sigma=10)

pn.panel(plot).servable()

Command to start:

python -m panel serve app.py --autoreload --show --admin

What I see

After opening the admin panel, I get these (roughly once per second):

2024-01-23 10:53:59,751 Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x7f404332c760>>, <Task finished name='Task-11763' coro=<ServerSession.with_document_locked() done, defined at /home/niko/myproj/.venvs/venv/lib/python3.10/site-packages/bokeh/server/session.py:77> exception=ValueError('"Session 139913982740368 executing periodic callback \'_reload_on_update\' (216)" is not in list')>)
Traceback (most recent call last):
  File "/home/niko/myproj/.venvs/venv/lib/python3.10/site-packages/tornado/ioloop.py", line 750, in _run_callback
    ret = callback()
  File "/home/niko/myproj/.venvs/venv/lib/python3.10/site-packages/tornado/ioloop.py", line 774, in _discard_future_result
    future.result()
  File "/home/niko/myproj/.venvs/venv/lib/python3.10/site-packages/bokeh/server/session.py", line 94, in _needs_document_lock_wrapper
    result = func(self, *args, **kwargs)
  File "/home/niko/myproj/.venvs/venv/lib/python3.10/site-packages/bokeh/server/session.py", line 226, in with_document_locked
    return func(*args, **kwargs)
  File "/home/niko/myproj/.venvs/venv/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 485, in wrapper
    return invoke_with_curdoc(doc, invoke)
  File "/home/niko/myproj/.venvs/venv/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 443, in invoke_with_curdoc
    return f()
  File "/home/niko/myproj/.venvs/venv/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 484, in invoke
    return f(*args, **kwargs)
  File "/home/niko/myproj/.venvs/venv/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 182, in remove_then_invoke
    return callback()
  File "/home/niko/myproj/.venvs/venv/lib/python3.10/site-packages/panel/io/admin.py", line 231, in update_cds
    index = cds.data['msg'].index(msg.replace('finished executing', 'executing'))
ValueError: "Session 139913982740368 executing periodic callback '_reload_on_update' (216)" is not in list

Question

Why I’m getting the ValueError and how to get rid of it?


Update: The ValueError occurs only if --autoreload is used with --admin
Update: Also occurring when using panel 1.2.3 or panel 1.3.7 instead of panel 1.3.6
Update: Also occurring when using panel 1.3.7 + bokeh 3.3.3 and bokeh 3.1.1 (instead of bokeh 3.2.2)

Is this a bug or expected behaviour? If --autoreload should not be used with --admin, it would be better that the app would crash on start and explain that the flags are not compatible with each other.