Skip to content

Exceptions thrown by network stack (websocket/http/socket) frequently lack stack traces #44994

@jonahwilliams

Description

@jonahwilliams

The dart websocket/http/socket libraries frequently throw errors with no meaningful stack traces attached. This makes it difficult to identify parts of the flutter_tool code that need additional error handling. Generally what I'd like is for errors thrown during the course of a particular request to contain a stack trace that was created where the user code initiated the request.

This can easily happen if a Completer is completed with an error but no stack trace, though there are other constructs that have a similar effect:

A related example from the socket_impl: the following code does not return a meaningful stack trace, printing an empty string for the stack trace.

import 'dart:io';

Future<void> main() async {
  try {
    await foo();
  } catch (err, st) {
    print('err: $err, st: $st');
   }
}

Future<void> foo() async {
  await WebSocket.connect('ws://localhost:8181/ws'); // Nothing actually running here
}

Some of the other errors are harder to hit, but hopefully the SDK has an existing http test suite that could be exercised here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-iotype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions