MCPcopy
hub / github.com/microsoft/vscode-js-debug / restart

Function restart

src/targets/node/nodeLauncherBase.ts:195–228  ·  view source on GitHub ↗

* Restarts the ongoing program.

(newParams: AnyLaunchConfiguration)

Source from the content-addressed store, hash-verified

193 * Restarts the ongoing program.
194 */
195 public async restart(newParams: AnyLaunchConfiguration): Promise<void> {
196 if (!this.run) {
197 return;
198 }
199
200 // Clear the program so that termination logic doesn't run.
201 const program = this.program;
202 if (program) {
203 this.program = undefined;
204 await program.stop();
205
206 const closeOk = await Promise.race([
207 delay(2000).then(() => false),
208 Promise.all([...this.serverConnections].map(c => new Promise(r => c.onDisconnected(r)))),
209 ]);
210
211 if (!closeOk) {
212 this.logger.warn(LogTag.RuntimeLaunch, 'Timeout waiting for server connections to close');
213 this.closeAllConnections();
214 }
215 }
216
217 // relaunch the program, releasing the initial cancellation token:
218 await this.launchProgram({
219 ...this.run,
220 params: newParams ? this.resolveParams(newParams) ?? this.run.params : this.run.params,
221 context: {
222 ...this.run.context,
223 cancellationToken: this.run.params.timeout > 0
224 ? CancellationTokenSource.withTimeout(this.run.params.timeout).token
225 : NeverCancelled,
226 },
227 });
228 }
229
230 public targetList(): ITarget[] {
231 return [...this.targets.value()];

Callers 1

doLaunchMethod · 0.70

Calls 8

delayFunction · 0.90
allMethod · 0.80
mapMethod · 0.80
withTimeoutMethod · 0.80
stopMethod · 0.65
warnMethod · 0.65
launchProgramMethod · 0.65
resolveParamsMethod · 0.45

Tested by

no test coverage detected