Skip to content

Commit

Permalink
Use @pragma('vm:awaiter-link') for better stacktraces
Browse files Browse the repository at this point in the history
  • Loading branch information
codedbycurtis committed Sep 11, 2024
1 parent 551c93f commit 2e835da
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions dio/lib/src/cancel_token.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'options.dart';
class CancelToken {
CancelToken();

@pragma('vm:awaiter-link')
final Completer<DioException> _completer = Completer<DioException>();

/// Whether the [error] is thrown by [cancel].
Expand Down
1 change: 1 addition & 0 deletions dio/lib/src/compute/compute_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Future<R> compute<Q, R>(
Timeline.finishSync();
}

@pragma('vm:awaiter-link')
final Completer<dynamic> completer = Completer<dynamic>();
port.handler = (dynamic msg) {
timeEndAndCleanup();
Expand Down
1 change: 1 addition & 0 deletions dio/lib/src/dio/dio_for_native.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class DioForNative with DioMixin implements Dio {
RandomAccessFile raf = file.openSync(mode: FileMode.write);

// Create a Completer to notify the success/error state.
@pragma('vm:awaiter-link')
final completer = Completer<Response>();
int received = 0;

Expand Down
1 change: 1 addition & 0 deletions dio/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const kReleaseMode = bool.fromEnvironment('dart.vm.product');
/// [stream] is done. Unlike [store], [sink] remains open after [stream] is
/// done.
Future<void> writeStreamToSink<T>(Stream<T> stream, EventSink<T> sink) {
@pragma('vm:awaiter-link')
final completer = Completer<void>();
stream.listen(
sink.add,
Expand Down
1 change: 1 addition & 0 deletions dio/test/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class ByteStream extends StreamView<List<int>> {

/// Collects the data of this stream in a [Uint8List].
Future<Uint8List> toBytes() {
@pragma('vm:awaiter-link')
final completer = Completer<Uint8List>();
final sink = ByteConversionSink.withCallback(
(bytes) => completer.complete(Uint8List.fromList(bytes)),
Expand Down
2 changes: 2 additions & 0 deletions dio_test/lib/src/test/cancellation_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ void cancellationTests(
test('cancel multiple requests with single token', () async {
final token = CancelToken();

@pragma('vm:awaiter-link')
final receiveSuccess1 = Completer();
@pragma('vm:awaiter-link')
final receiveSuccess2 = Completer();
final futures = [
dio.get(
Expand Down
1 change: 1 addition & 0 deletions dio_test/lib/src/test/download_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ void downloadTests(
cancelToken.cancel();
});

@pragma('vm:awaiter-link')
final completer = Completer<Never>();
res.data!.stream.listen(
(event) {},
Expand Down
1 change: 1 addition & 0 deletions dio_test/lib/src/test/timeout_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void timeoutTests(
'with streamed response',
() async {
dio.options.receiveTimeout = const Duration(seconds: 1);
@pragma('vm:awaiter-link')
final completer = Completer<void>();
final streamedResponse = await dio.get(
'/drip',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class ConversionLayerAdapter implements HttpClientAdapter {
options.method,
options.uri,
);
@pragma('vm:awaiter-link')
final completer = Completer<Uint8List>();
final sink = ByteConversionSink.withCallback(
(bytes) => completer.complete(
Expand Down
1 change: 1 addition & 0 deletions plugins/http2_adapter/lib/src/connection_manager_imp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ class _ConnectionManager implements ConnectionManager {
proxySocket.write(crlf);
proxySocket.write(crlf);

@pragma('vm:awaiter-link')
final completerProxyInitialization = Completer<void>();

Never onProxyError(Object? error, StackTrace stackTrace) {
Expand Down
1 change: 1 addition & 0 deletions plugins/http2_adapter/lib/src/http2_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class Http2Adapter implements HttpClientAdapter {

final responseSink = StreamController<Uint8List>();
final responseHeaders = Headers();
@pragma('vm:awaiter-link')
final responseCompleter = Completer();
late StreamSubscription responseSubscription;
bool needRedirect = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ConversionLayerAdapter implements HttpClientAdapter {
request.maxRedirects = options.maxRedirects;

if (requestStream != null) {
@pragma('vm:awaiter-link')
final completer = Completer<Uint8List>();
final sink = ByteConversionSink.withCallback(
(bytes) => completer.complete(
Expand Down
1 change: 1 addition & 0 deletions plugins/web_adapter/lib/src/adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class BrowserHttpClientAdapter implements HttpClientAdapter {
final xhrTimeout = (connectTimeout + receiveTimeout).inMilliseconds;
xhr.timeout = xhrTimeout;

@pragma('vm:awaiter-link')
final completer = Completer<ResponseBody>();

xhr.onLoad.first.then((_) {
Expand Down

0 comments on commit 2e835da

Please sign in to comment.