You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pull request introduces several improvements and fixes related to WebSocket connection handling, testing, and code quality for the application. The main focus is on making the WebSocket middleware more robust against race conditions, improving test coverage, and adding development tooling. Below are the most important changes:
WebSocket Middleware Robustness and Reliability:
Refactored websocketMiddleware to ensure only the latest WebSocket instance can dispatch actions, preventing race conditions and stale event handlers from interfering with the current connection. Added a closeSocket helper to clean up handlers before closing, and improved fallback handling logic. (src/store/websocketMiddleware.ts) [1][2][3][4]
Updated the session join logic in App.tsx to prevent multiple simultaneous session requests using a useRef guard, ensuring only one join attempt is in flight at a time. (src/App.tsx)
Testing Improvements:
Added comprehensive tests for the WebSocket middleware, including connection deduplication, fallback logic, and disconnection, using a FakeWebSocket stand-in and Vitest. (src/store/websocketMiddleware.test.ts)
Updated the main app test to use Redux and React Router providers, and added a test for rendering the help page. (src/App.test.tsx)
Development Tooling:
Added eslint as a development dependency to enforce code quality. (package.json)
Repository Configuration:
Added a .gitattributes file to enforce consistent LF line endings across the repository. (.gitattributes)
The repository already stores all text files with LF; this keeps
Windows editors and tooling from committing CRLF.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sages
Detach handlers before closing a socket and ignore events from any
socket that is no longer current, so a replaced connection can't keep
dispatching messages, clobber the active socket, or trigger a spurious
fallback. WS_DISCONNECT now also dispatches disconnected() since the
detached onclose no longer does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nding
Rapid clicks on Join started multiple debug sessions and sockets,
producing duplicate console messages.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The server already returns the URL reachable from the browser's side of
the network, so connect to `url` first and use `fallbackUrl` only as the
fallback instead of swapping them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hey @ndorin could you please have look at this PR when you have a moment? I ran into this issue when using Debug Console testing a client mock system for Essentials v3 platform.
- eslint.config.js: @eslint/js + typescript-eslint recommended, React
hooks, Vite react-refresh, plus type-aware no-floating-promises and
no-misused-promises; eslint-config-prettier last to avoid conflicts
- Rename prettierrc.json to .prettierrc.json so Prettier finds it, and
add .prettierignore
- Add lint, lint:fix, format and format:check scripts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GitHub applies .git-blame-ignore-revs automatically; locally run
`git config blame.ignoreRevsFile .git-blame-ignore-revs`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Log failures from join() instead of leaving an unhandled rejection
when starting a debug session fails
- Mark fire-and-forget RTK Query triggers, refetch() and navigate() with
`void` (their promises don't reject without unwrap())
- Wrap async click/submit handlers so React gets a void callback
- Replace `any` with `unknown` or a narrow type for the legacy monaco
languages.json API; String -> string in LogMessage
- Remove unused getAppIdFromPath; rename icons/index.tsx to .ts since it
holds no components
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Drop legacy eslint.options.extensions (removed in ESLint 10), the
prettier/prettier rule customization, html validation and the
deprecated eslint.alwaysShowStatus; the default eslint.validate also
covers .tsx, which the old list missed
- Use Prettier as the default formatter and format on save
- Recommend the ESLint and Prettier extensions
- Document the lint and format scripts in the README
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ESLint 10, jsdom 29 and Vite 8 require Node ^20.19.0 || ^22.13.0 || >=24,
so Node 18 is no longer supported. Update the README prerequisite and
declare the range in package.json engines.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the join ref, which was released before the WebSocket opened,
with an isConnecting flag in the websocket slice. It is set when a join
begins and cleared when the socket opens, fails, or disconnects, and the
Start button is disabled while it is set.
Dispatch disconnected() when replacing a socket, since its detached
onclose no longer reports it, so a failed reconnect can't leave
isConnected stuck at true.
Exercise the stale socket's captured handlers in the middleware tests
and cover reconnect failure and the isConnecting lifecycle.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Clear connection state when fallback connection fails
src/store/websocketSlice.ts:45
When an already-open primary socket errors, this branch closes it and tries the fallback without dispatching disconnected(). If the fallback then errors, connectionFailed only clears isConnecting, so isConnected remains true and the UI reports a connected session even though socket is gone; clear isConnected when recording a connection failure and add a regression test for this sequence.
Addressed in f26a904. Stale start-session responses are now ignored after app navigation, route changes clear the active debug-session connection state, terminal websocket failures clear isConnected, and the added regressions cover both stale responses and fallback failure handling.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements and fixes related to WebSocket connection handling, testing, and code quality for the application. The main focus is on making the WebSocket middleware more robust against race conditions, improving test coverage, and adding development tooling. Below are the most important changes:
WebSocket Middleware Robustness and Reliability:
Refactored
websocketMiddlewareto ensure only the latest WebSocket instance can dispatch actions, preventing race conditions and stale event handlers from interfering with the current connection. Added acloseSockethelper to clean up handlers before closing, and improved fallback handling logic. (src/store/websocketMiddleware.ts) [1] [2] [3] [4]Updated the session join logic in
App.tsxto prevent multiple simultaneous session requests using auseRefguard, ensuring only one join attempt is in flight at a time. (src/App.tsx)Testing Improvements:
Added comprehensive tests for the WebSocket middleware, including connection deduplication, fallback logic, and disconnection, using a
FakeWebSocketstand-in and Vitest. (src/store/websocketMiddleware.test.ts)Updated the main app test to use Redux and React Router providers, and added a test for rendering the help page. (
src/App.test.tsx)Development Tooling:
eslintas a development dependency to enforce code quality. (package.json)Repository Configuration:
.gitattributesfile to enforce consistent LF line endings across the repository. (.gitattributes)Closes #44