Skip to content

Commit 4054b4b

Browse files
authored
feat: deprecated API alert (#10366)
1 parent 55ac7d3 commit 4054b4b

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

server.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,28 @@ async def send_socket_catch_exception(function, message):
4848
except (aiohttp.ClientError, aiohttp.ClientPayloadError, ConnectionResetError, BrokenPipeError, ConnectionError) as err:
4949
logging.warning("send error: {}".format(err))
5050

51+
# Track deprecated paths that have been warned about to only warn once per file
52+
_deprecated_paths_warned = set()
53+
54+
@web.middleware
55+
async def deprecation_warning(request: web.Request, handler):
56+
"""Middleware to warn about deprecated frontend API paths"""
57+
path = request.path
58+
59+
if (path.startswith('/scripts/') or path.startswith('/extensions/core/')):
60+
# Only warn once per unique file path
61+
if path not in _deprecated_paths_warned:
62+
_deprecated_paths_warned.add(path)
63+
logging.warning(
64+
f"[DEPRECATION WARNING] Detected import of deprecated legacy API: {path}. "
65+
f"This is likely caused by a custom node extension using outdated APIs. "
66+
f"Please update your extensions or contact the extension author for an updated version."
67+
)
68+
69+
response: web.Response = await handler(request)
70+
return response
71+
72+
5173
@web.middleware
5274
async def compress_body(request: web.Request, handler):
5375
accept_encoding = request.headers.get("Accept-Encoding", "")
@@ -159,7 +181,7 @@ def __init__(self, loop):
159181
self.client_session:Optional[aiohttp.ClientSession] = None
160182
self.number = 0
161183

162-
middlewares = [cache_control]
184+
middlewares = [cache_control, deprecation_warning]
163185
if args.enable_compress_response_body:
164186
middlewares.append(compress_body)
165187

0 commit comments

Comments
 (0)