Giter Club home page Giter Club logo

Comments (6)

bkonyi avatar bkonyi commented on June 28, 2024

@derekxu16 can you take a look when you have a chance?

from sdk.

DanTup avatar DanTup commented on June 28, 2024

Possibly related to this (but if not I can file another issue), the call to DartDevelopmentService.startDartDevelopmentService never completes when trying to connect to another instance of DDS when it's run in a zone (which is the only workaround I have for the above).

This code will never print 2, 3 or 4 (when run in debug mode such that it already has a DDS instance) :

import 'dart:async';
import 'dart:developer';

import 'package:dds/dds.dart';

Future<void> main() async {
  try {
    final serviceInfo = await Service.getInfo();

    // Try to connect DDS to an existing version in a zone to handle errors.
    final dds = await runZonedGuarded(
      () => DartDevelopmentService.startDartDevelopmentService(
          serviceInfo.serverUri!),
      (error, stack) {
        print('1: Failed to start DDS: $error');
      },
    );
    print('2: Done!');
  } catch (e) {
    print('3: Error: $e');
  }
  print('4: Done!');
}

image

This makes it a bit messy to spawn DDS in DAP, because we'd have to use a Zone, and then also a completer to continue when either an error occurs or startDartDevelopmentService completes (and then we need to ensure that if two errors occur in the handler, or an error occurs and it returns, we don't try to complete the completer twice).

from sdk.

bkonyi avatar bkonyi commented on June 28, 2024

Possibly related to this (but if not I can file another issue)

This issue felt familiar, so I did some digging and found this: flutter/flutter#141821

Basically, this is just the behavior of zones, which is kind of gross.

from sdk.

DanTup avatar DanTup commented on June 28, 2024

Ah, thanks for the info, that explains what I see. I handled this by using a completer in https://dart-review.googlesource.com/c/sdk/+/366662 but that's also quite gross, so if we could eliminate the need for a zone (the original issue here) we can remove than and just have the original simple try/catch :-)

from sdk.

derekxu16 avatar derekxu16 commented on June 28, 2024

@bkonyi, so is our goal here to make exceptions thrown when starting DDS catchable? This webSocketBuilder call currently doesn't run in a Zone with an error handler:

_vmServiceSocket = webSocketBuilder(remoteVmServiceWsUri);

So I think that if we want to make exceptions thrown when starting DDS catchable, we have to wrap that webSocketBuilder call with a Completer + runZonedGuarded similarly to what @DanTup did in his CL.

from sdk.

bkonyi avatar bkonyi commented on June 28, 2024

Yeah, basically we just don't want unhandled asynchronous exceptions to leak out of DDS. If it makes sense to throw (e.g., if remoteVmServiceWsUri points to a VM service that doesn't exist) we should throw synchronously. If it makes sense to swallow an exception (e.g., the VM service connection disappears, which indicates we DDS should shutdown), we should do that and shutdown gracefully.

from sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.