Repository navigation
Conversation
theluckystrike
added a commit
to theluckystrike/appium-flutter-driver
that referenced
this pull request
Nov 2, 2026
…nnectSocket
Review follow-up for the two gaps in the previous commit.
The socket.call wrapper in connectSocket logged and swallowed every
error, so a call rejected by the disconnect resolved with undefined.
executeElementCommand turned that into an error, but enterText,
requestData, setFrameSync and the other handlers that call
executeSocketCommand directly returned undefined as a success. The
wrapper now rethrows DartVmConnectionClosedError, the error used to
reject pending calls on `close`. A call made while the connection is
down ("socket not ready") is rethrown as the same error. Other errors
are still logged and swallowed as before.
During the initial VM lookup the rejected getVM call made the async
`open` listener read `vm.isolates` of undefined. Nothing awaited the
listener, so the TypeError was an unhandled rejection and the
connection promise never settled. The setup now runs in setUpSocket,
and the `open` listener settles the connection promise with a failure
(and closes the socket) when setUpSocket rejects. connectSocket then
throws its usual "Cannot connect to the Dart Observatory URL" error.
Since appium#948 the isolate lookup runs inside retryInterval. A closed
connection can't recover, so the lookup stops retrying on
DartVmConnectionClosedError and fails the setup right away instead of
retrying for 15 seconds.
Tests: a disconnect during getVM rejects connectSocket without an
unhandled rejection, and flutter:enterText through `execute` rejects
on a disconnect, both during the call and right after it.
KazuCocoa
pushed a commit
that referenced
this pull request
Nov 3, 2026
…tion closes (#937) * fix(driver): fail commands instead of hanging when the Dart VM connection closes rpc-websockets 10.0.1 keeps a pending call until a reply or its timeout arrives, and executeSocketCommand sets no timeout. When the Dart VM socket closes during a command (app crash or relaunch), the call never settles and the Appium command hangs until newCommandTimeout. IsolateSocket now rejects pending calls on `close`. rpc-websockets emits `close` only after it set `ready` to false, so calls made after the drop are already refused with "socket not ready" and only calls from the dead socket are in the queue. The connect wrapper turns a rejection into an undefined result. executeElementCommand now throws a clear error for an empty reply instead of a TypeError on `data.isError`. The wrapper also logged `JSON.stringify(e)`, which is `{}` for an Error. It now logs the Error itself, so the server log names the cause the new message points to. Fixes #733 I ran these in driver/ on this commit (main base e13a971), Node 22.23.2. ``` $ npm test main lib + new tests tests 7 pass 5 fail 2 rejects a pending command when the Dart VM connection closes test timed out after 5000ms fails an element command instead of hanging when the Dart VM ... test timed out after 5000ms this commit tests 7 pass 7 fail 0 $ npm run lint exit 0 $ npm run format:check All matched files use the correct format. ``` End to end I ran the call the Appium router makes, `FlutterDriver.executeCommand('execute', 'flutter:waitForAbsent', [finder])`, against a fake Dart VM service. It drops the socket mid-command and never replies, the way a crashing app does. ``` main info Connection to ws://127.0.0.1:53066/ws closed executeCommand('execute', 'flutter:waitForAbsent') -> STILL PENDING after 15000 ms (hang) this commit info Connection to ws://127.0.0.1:53104/ws closed ERR! Error: The Dart VM connection was closed before it replied executeCommand('execute', 'flutter:waitForAbsent') -> rejected: Cannot execute command waitForAbsent, no response from the Dart VM. Check the server log for the connection error [4 ms] ``` I didn't run the device functional workflow (driver-function.yml) because it needs an iOS simulator with a built Flutter app. * fix(driver): propagate Dart VM disconnects to every command and to connectSocket Review follow-up for the two gaps in the previous commit. The socket.call wrapper in connectSocket logged and swallowed every error, so a call rejected by the disconnect resolved with undefined. executeElementCommand turned that into an error, but enterText, requestData, setFrameSync and the other handlers that call executeSocketCommand directly returned undefined as a success. The wrapper now rethrows DartVmConnectionClosedError, the error used to reject pending calls on `close`. A call made while the connection is down ("socket not ready") is rethrown as the same error. Other errors are still logged and swallowed as before. During the initial VM lookup the rejected getVM call made the async `open` listener read `vm.isolates` of undefined. Nothing awaited the listener, so the TypeError was an unhandled rejection and the connection promise never settled. The setup now runs in setUpSocket, and the `open` listener settles the connection promise with a failure (and closes the socket) when setUpSocket rejects. connectSocket then throws its usual "Cannot connect to the Dart Observatory URL" error. Since #948 the isolate lookup runs inside retryInterval. A closed connection can't recover, so the lookup stops retrying on DartVmConnectionClosedError and fails the setup right away instead of retrying for 15 seconds. Tests: a disconnect during getVM rejects connectSocket without an unhandled rejection, and flutter:enterText through `execute` rejects on a disconnect, both during the call and right after it. * fix(driver): stop the reconnect of a socket abandoned during setup When the connection drops during getVM, rpc-websockets 10.0.1 clears its socket and schedules a reconnect (reconnect_timer_id) before the `close` event fires. Client.close() only closes an existing socket, so the setup-failure path did nothing: the abandoned client reconnected about a second later and left an unmanaged connection open. Turning `reconnect` off alone isn't enough because the scheduled callback calls _connect() anyway. IsolateSocket.dispose() turns automatic reconnection off, clears the scheduled reconnect timer and closes any open socket. connectSocket calls it when the setup fails. The regression test no longer closes the leaked reconnect from the server. It now asserts that the server sees no new connection for 2 s after the setup fails, which is longer than the 1 s reconnect interval.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.