Add a retry to the DevTools handler for static files

Change-Id: Iced8093f894afd5574e3ae898e07f237e02002bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325323
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
This commit is contained in:
Kenzie Schmoll 2023-09-12 18:52:01 +00:00 committed by Commit Queue
parent f0632629c3
commit 83b27b8bcf
3 changed files with 19 additions and 4 deletions

View file

@ -1,12 +1,16 @@
# 2.11.0
- Added a retry to the DevTools handler for serving static files.
- Updated `devtools_shared` to ^4.0.0.
# 2.10.0
- Updated `devtools_shared` to ^3.0.0
- Updated `devtools_shared` to ^3.0.0.
# 2.9.5
- [DAP] The change to use VM Service Isolate numbers for `threadId`s has been reverted because Isolate numbers can be larger than the 32-bit integers allowed in DAP.
- [DAP] Threads returned from `threadsRequest` from the DDS DAP handler now include `isolateId` fields to allow mapping back to VM Service Isolates.
# 2.9.4
- Updated `devtools_shared` to ^2.26.1
- Updated `devtools_shared` to ^2.26.1.
# 2.9.3
- [DAP] `threadId`s generated by the debug adapter now match the Isolate numbers of the underlying isolates.

View file

@ -5,6 +5,7 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';
import 'package:devtools_shared/devtools_deeplink.dart';
import 'package:devtools_shared/devtools_extensions_io.dart';
@ -165,7 +166,17 @@ Future<Response> _serveStaticFile(
final headers = {HttpHeaders.contentTypeHeader: contentType};
if (contentType != 'text/html') {
return Response.ok(file.readAsBytesSync(), headers: headers);
late final Uint8List fileBytes;
try {
fileBytes = file.readAsBytesSync();
} on PathNotFoundException catch (_) {
// Wait a short delay, and then retry in case we have hit a race condition
// between a static file being served and accessed. See
// https://github.com/flutter/devtools/issues/6365.
await Future.delayed(Duration(milliseconds: 500));
fileBytes = file.readAsBytesSync();
}
return Response.ok(fileBytes, headers: headers);
}
var contents = file.readAsStringSync();

View file

@ -1,5 +1,5 @@
name: dds
version: 2.10.0
version: 2.11.0
description: >-
A library used to spawn the Dart Developer Service, used to communicate with
a Dart VM Service instance.