Unverified Commit c8e8d553 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Allow tests to override _DevFSHttpWriter._startWrite throttle time (#74545)

parent 9baca0c3
......@@ -228,15 +228,18 @@ class _DevFSHttpWriter implements DevFSWriter {
@required OperatingSystemUtils osUtils,
@required HttpClient httpClient,
@required Logger logger,
Duration uploadRetryThrottle,
})
: httpAddress = serviceProtocol.httpAddress,
_client = httpClient,
_osUtils = osUtils,
_uploadRetryThrottle = uploadRetryThrottle,
_logger = logger;
final HttpClient _client;
final OperatingSystemUtils _osUtils;
final Logger _logger;
final Duration _uploadRetryThrottle;
final String fsName;
final Uri httpAddress;
......@@ -320,7 +323,7 @@ class _DevFSHttpWriter implements DevFSWriter {
if (retry > 0) {
retry--;
_logger.printTrace('trying again in a few - $retry more attempts left');
await Future<void>.delayed(const Duration(milliseconds: 500));
await Future<void>.delayed(_uploadRetryThrottle ?? const Duration(milliseconds: 500));
continue;
}
_completer.completeError(error, trace);
......@@ -364,6 +367,8 @@ class UpdateFSReport {
class DevFS {
/// Create a [DevFS] named [fsName] for the local files in [rootDirectory].
///
/// Failed uploads are retried after [uploadRetryThrottle] duration, defaults to 500ms.
DevFS(
vm_service.VmService serviceProtocol,
this.fsName,
......@@ -372,6 +377,7 @@ class DevFS {
@required Logger logger,
@required FileSystem fileSystem,
HttpClient httpClient,
Duration uploadRetryThrottle,
}) : _vmService = serviceProtocol,
_logger = logger,
_fileSystem = fileSystem,
......@@ -380,6 +386,7 @@ class DevFS {
serviceProtocol,
osUtils: osUtils,
logger: logger,
uploadRetryThrottle: uploadRetryThrottle,
httpClient: httpClient ?? ((context.get<HttpClientFactory>() == null)
? HttpClient()
: context.get<HttpClientFactory>()())
......
......@@ -219,6 +219,7 @@ void main() {
fileSystem: fileSystem,
logger: BufferLogger.test(),
httpClient: httpClient,
uploadRetryThrottle: Duration.zero,
);
await devFS.create();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment