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

Function startDebugServer

src/debugServer.ts:85–126  ·  view source on GitHub ↗
(port: number, host?: string)

Source from the content-addressed store, hash-verified

83}
84
85export function startDebugServer(port: number, host?: string): Promise<IDisposable> {
86 return new Promise((resolve, reject) => {
87 const server = net
88 .createServer(async socket => {
89 const services = createTopLevelSessionContainer(
90 createGlobalContainer({ storagePath, isVsCode: false }),
91 );
92 const binderDelegate: IBinderDelegate = {
93 async acquireDap(): Promise<DapConnection> {
94 // Note: we can make multi-session work through custom dap message:
95 // - spin up a separate server for this session;
96 // - ask ui part to create a session for us and connect to the port;
97 // - marshall target name changes across.
98 return connection;
99 },
100
101 async initAdapter(debugAdapter: DebugAdapter): Promise<boolean> {
102 await configurator.configure(debugAdapter);
103 return true;
104 },
105
106 releaseDap(): void {
107 // no-op
108 },
109 };
110
111 const transport = new StreamDapTransport(socket, socket, services.get(ILogger));
112 const connection = new DapConnection(transport, services.get(ILogger));
113 new Binder(binderDelegate, connection, services, new TargetOrigin('targetOrigin'));
114 const configurator = new Configurator(connection.dap());
115 })
116 .on('error', reject)
117 .listen({ port, host }, () => {
118 console.log(`Debug server listening at ${(server.address() as net.AddressInfo).port}`);
119 resolve({
120 dispose: () => {
121 server.close();
122 },
123 });
124 });
125 });
126}

Callers 1

debugServerMain.tsFile · 0.90

Calls 10

createGlobalContainerFunction · 0.90
resolveFunction · 0.85
listenMethod · 0.80
createServerMethod · 0.80
dapMethod · 0.80
onMethod · 0.65
getMethod · 0.65
logMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected