mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-09-04 14:45:41 +00:00
fix: Distributed API proxy memory leak, node switcher refresh, and copy button
Proxy memory leak (MaxListenersExceededWarning + DEP0060): createProxyMiddleware was instantiated inside the request handler on every single API call. Each new instance registered fresh 'close' listeners on the HTTP server and re-ran the http-proxy util._extend deprecated path. After ~10 requests the MaxListeners threshold was breached. Fix: declare ONE global remoteNodeProxy at startup using the router option to dynamically resolve the target URL per request. Listeners are registered once. ECONNREFUSED errors are caught in the on.error handler and returned as structured 502 JSON. Node switcher "nothing happens": EditorLayout had a single useEffect([], []) that called refreshStacks() once on mount. Changing the active node updated NodeContext state and localStorage but nothing re-triggered the stack list fetch. Fix: split into two effects — notifications polling (no dependency) and a stack-refresh effect keyed on activeNode?.id. When the node changes, stale editor/container/file state is cleared and the stacks for the new node are fetched. Copy button silently failing: navigator.clipboard.writeText() throws DOMException in non-HTTPS / non-localhost contexts (e.g. http://192.168.x.x). The uncaught async exception silently swallowed the success toast and state update. Fix: wrapped in try/catch with an execCommand('copy') textarea fallback and a final error toast if both fail.
This commit is contained in:
@@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
- **Fixed:** Backend memory leak caused by improper proxy middleware instantiation — `createProxyMiddleware` was called inside the request handler on every API call, spawning a new `http-proxy` instance (and registering new server listeners) per request. Refactored to a single globally-instantiated proxy using the `router` option for dynamic per-request target resolution.
|
||||
- **Fixed:** `[DEP0060] DeprecationWarning: util._extend` deprecation eliminated as a side-effect of the above fix (deprecation was triggered on every new `http-proxy` initialisation).
|
||||
- **Fixed:** Remote node authentication failures — `authMiddleware` and WebSocket upgrade handler both accept `Authorization: Bearer` tokens (Sencho-to-Sencho proxy auth).
|
||||
- **Fixed:** Node connection testing logic updated to perform authenticated HTTP pings to `/api/auth/check` on the remote instance.
|
||||
- **Fixed:** Node switcher dropdown failing to trigger data refreshes — `EditorLayout` now reacts to `activeNode` changes, re-fetching stacks and clearing stale editor/container state when the user switches nodes.
|
||||
- **Fixed:** API Token copy button failing silently on HTTP / non-localhost deployments where `navigator.clipboard` is unavailable — added `try/catch` with `document.execCommand('copy')` fallback.
|
||||
- **Fixed:** Remote node authentication failures by updating middleware to support Bearer tokens in WebSocket upgrade handler (node-to-node WS proxy now authenticates correctly on the receiving instance).
|
||||
- **Fixed:** Node connection testing logic updated to normalize `api_url` trailing slashes before constructing the authenticated HTTP ping URL.
|
||||
- **Fixed:** Memory leak in `GlobalObservabilityView` SSE mode — log array now capped at 10,000 entries (`.slice(-10000)`) to prevent unbounded accumulation across long sessions.
|
||||
|
||||
Reference in New Issue
Block a user