MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / subscribeToStreams

Function subscribeToStreams

src/debug/dart_debug_impl.ts:374–407  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

372 }
373
374 private async subscribeToStreams(): Promise<void> {
375 if (!this.vmService)
376 return;
377
378 const serviceStreamName = this.vmServiceCapabilities.serviceStreamIsPublic ? "Service" : "_Service";
379 await Promise.all([
380 this.vmService.on("Isolate", (event: VMEvent) => this.handleIsolateEvent(event)),
381 this.vmService.on("Debug", (event: VMEvent) => this.handleDebugEvent(event)),
382 this.vmService.on(serviceStreamName, (event: VMEvent) => this.handleServiceEvent(event)),
383 ]);
384
385 if (this.vmServiceCapabilities.hasLoggingStream && this.showDartDeveloperLogs) {
386 await this.vmService.on("Logging", (event: VMEvent) => this.handleLoggingEvent(event)).catch((e) => {
387 // For web, the protocol version says this is supported, but it throws.
388 // TODO: Remove this catch block if/when the stable release does not throw.
389 this.logger.info(errorString(e));
390 });
391 }
392
393 // We don't know for certain we have a connected DDS that supports custom streams, so wrap in try/catch
394 try {
395 await this.vmService.on("ToolEvent", (event: VMEvent) => this.handleToolEvent(event)).catch((e) => {
396 this.logger.info(errorString(e));
397 });
398 } catch (e) { }
399
400 if (this.subscribeToStdout) {
401 await this.vmService.on("Stdout", (event: VMWriteEvent) => this.handleStdoutEvent(event)).catch((e) => {
402 // Some embedders may not provide Stdout and it's not clear if they will throw, so
403 // just catch/log errors here.
404 this.logger.info(errorString(e));
405 });
406 }
407 }
408
409 protected async terminate(force: boolean): Promise<void> {
410 const signal = force ? "SIGKILL" : "SIGINT";

Callers

nothing calls this directly

Calls 4

errorStringFunction · 0.90
onMethod · 0.80
handleDebugEventMethod · 0.80
infoMethod · 0.65

Tested by

no test coverage detected