Code Monkey home page Code Monkey logo

Comments (4)

DanTup avatar DanTup commented on September 28, 2024

This might be something in the daemon... I can repro this with the following code:

for (let i = 0; i < 10; i++) {
	const process = safeSpawn(undefined, "C:\\Dev\\Tools\\Dart\\Nightly\\bin\\dart.exe", [
		"tooling-daemon",
		"--machine",
	], {});

	console.log(`    Spawned PID: ${process.pid}`);

	process.stdout.on("data", (data: Buffer | string) => console.log(data));
	process.stderr.on("data", (data: Buffer | string) => console.error(data));
	process.on("exit", (code, signal) => console.warn(code, signal));
	process.on("error", (error) => console.error(error));

	await new Promise((resolve) => setTimeout(resolve, 500));

	process.kill();
	console.log(`    Killed PID: ${process.pid}`);
}

image

@CoderDake FYI - I'll try to repro from Dart to eliminate NodeJS weirdness.

from dart-code.

DanTup avatar DanTup commented on September 28, 2024

Of course it doesn't happen from the equivalent Dart code 😬 I'll keep looking! My money is going to be on shell we're using to spawn it not passing across the signal. This is why many of our tools advertise pids during startup... I think maybe we should do the same here.

from dart-code.

DanTup avatar DanTup commented on September 28, 2024

Yep, enabling the shell on Windows triggers it from Dart too:

import 'dart:convert';
import 'dart:io';

Future<void> main() async {
  final vmPath = Platform.resolvedExecutable;
  final args = [
    'tooling-daemon',
    '--machine',
  ];

  for (int i = 0; i < 30; i++) {
    final proc = await Process.start(vmPath, args, runInShell: true);
    print('Started ${proc.pid}');
    proc.stdout.transform(utf8.decoder).listen(print);
    proc.stderr.transform(utf8.decoder).listen(print);

    await Future.delayed(const Duration(milliseconds: 100));
    proc.kill();
    print('Killed ${proc.pid}');
  }
}

The PIDs being printed here are the shell, not the Dart process.

@CoderDake any objections to putting the real PID inside the initial json?

{"pid":12345,"tooling_daemon_details":{"uri":"ws://127.0.0.1:53841/","trusted_client_secret":"apGxfEl4bIDvrYxR"}}
 ^^^^^

We do similar in DevTools server and other tools:

from dart-code.

DanTup avatar DanTup commented on September 28, 2024

For now, I'm going to bypass the shell for DTD - we know we don't need it. I've opened #5018 to see if we can bypass shells in other places to reduce the chance of possible leaving orphaned processes.

from dart-code.

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.