Cmd + . with routine playing occasionally leaves a dangling scsynth

hi! i’m new to Supercollider, so if this is something silly please let me know (but from searching around, i couldn’t find an answer to this specific problem).

more than a few times now i’ve run into an issue where i have a Routine going and i press cmd + ., which does stop the routine, but i end up still hearing any sounds that were playing at the moment finish - e.g. i can hear a synth through to the end of its envelope, or in one case i had an effect on the server tail and it persisted (even after closing the IDE).

when this happens, if i look at activity monitor i can see scsynth still there, but i have no way of actually communicating with the server via the IDE – if i try to get the node tree (via cmd option t) i get a blank window instead of the usual node tree, and i get a WARNING: Server failed to respond to Group:queryTree! in the post window. trying to kill and reboot via the IDE does not work either - i have to manually restart supercollider and kill the dangling scsynth from the activity monitor to restart anything.

i’m on an M2 Macbook Pro, if that is any clue as to what’s going on.

sorry if i’m just missing something obvious, but is this avoidable? i’ll include an example:

example code that can kill the IDE and leave a dangling scsynth

(i cribbed this from a nathan ho video)

s = Server.default;
s.boot;

(
SynthDef(\kick, {
	var snd;
	snd = SinOsc.ar(
		60
		* (1 + (3 * Env.perc(0,0.3, curve:-9).ar))
		* (1 + (3 * Env.perc(0,0.3, curve:-9).ar))
		* [1,5,10]
	);
	snd = (snd * [0,-5,-10].dbamp).sum;
	snd = snd + (BPF.ar(Hasher.ar(Sweep.ar), 12420, 0.3) * Env.perc(0.005,0.01).ar * 5.dbamp);
	snd = snd.tanh;
	snd = snd + MoogFF.ar(snd,ExpRand(1000,4000),3);
	snd = snd * Env.perc(0.005,1.0).ar(Done.freeSelf);

	Out.ar(0,snd.dup);
}).add;
)

(
Routine({
	var durations;
	loop {
		durations = (1.4 ** (1..10)).normalizeSum;
		durations.do{ |time|
			s.bind{
				Synth(\kick);
				time.wait;
			};
		};
		rrand(0.5,2.0).wait;
	};
}).play;
)

i can consistently replicate this behavior by starting the routine and pressing cmd .

about half the time it stops successfully but mostly it just leaves a dangling synth and i need to start the IDE over again.

I’m not sure if this will resolve everything, but I’d recommend strongly against something.wait inside a s.bind function.

		durations.do{ |time|
			s.bind{
				Synth(\kick);
			};
			time.wait;
		};

hjh

oh wow, that was a typo but actually, that’s most likely it – can’t seem to replicate it after moving that wait out. checked another scd that was i had noticed it with and i had also put a wait in bind. thanks so much for the catch!