@@ -151,6 +151,50 @@ void main() {
151151 expect (result.exitConfirmed, isTrue);
152152 });
153153
154+ test ('Helper lease retries stop after a transport failure' , () async {
155+ var stopRequests = 0 ;
156+ final client = _client (
157+ _ResponseAdapter ((options) {
158+ if (options.path.endsWith ('/start' )) {
159+ return _jsonResponse ({'sessionId' : _sessionId, 'pid' : 6456 });
160+ }
161+ stopRequests++ ;
162+ if (stopRequests == 1 ) {
163+ throw DioException (
164+ requestOptions: options,
165+ type: DioExceptionType .connectionError,
166+ );
167+ }
168+ return _jsonResponse ({
169+ 'sessionId' : _sessionId,
170+ 'stopped' : false ,
171+ 'reason' : 'notRunning' ,
172+ });
173+ }),
174+ );
175+ final launcher = WindowsHelperLauncher (client);
176+ final lease = await launcher.start (
177+ sessionId: _sessionId,
178+ address: 'test-address' ,
179+ );
180+
181+ await expectLater (
182+ lease.stop (const Duration (seconds: 1 )),
183+ throwsA (
184+ isA <WindowsHelperException >().having (
185+ (error) => error.code,
186+ 'code' ,
187+ 'transportError' ,
188+ ),
189+ ),
190+ );
191+ final result = await lease.stop (const Duration (seconds: 1 ));
192+
193+ expect (stopRequests, 2 );
194+ expect (result.stopped, isFalse);
195+ expect (result.exitConfirmed, isTrue);
196+ });
197+
154198 test (
155199 'Helper launcher compensates an uncertain start with exact stop' ,
156200 () async {
0 commit comments