MCPcopy Create free account
hub / github.com/Snapchat/Valdi / _doAttach

Method _doAttach

valdi/vscode_debugger/src/targets/node/nodeTarget.ts:158–183  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

156 }
157
158 async _doAttach(): Promise<Cdp.Api | undefined> {
159 this._waitingForDebugger = false;
160 this._attached = true;
161 const result = await this._cdp.Target.attachToTarget({ targetId: this._targetId });
162 if (!result) {
163 this.logger.info(LogTag.RuntimeLaunch, 'Failed to attach to target', {
164 targetId: this._targetId,
165 });
166 return; // timed out or cancelled, may have been a short-lived process
167 }
168
169 if (result && '__dynamicAttach' in result) {
170 await this._cdp.Debugger.enable({});
171 await this._cdp.Runtime.enable({});
172 }
173
174 let defaultCountextId: number;
175 this._cdp.Runtime.on('executionContextCreated', event => {
176 if (event.context.auxData && event.context.auxData['isDefault'])
177 defaultCountextId = event.context.id;
178 });
179 this._cdp.Runtime.on('executionContextDestroyed', event => {
180 if (event.executionContextId === defaultCountextId) this.connection.close();
181 });
182 return this._cdp;
183 }
184
185 public async afterBind() {
186 this._cdp.resume();

Callers 1

attachMethod · 0.95

Calls 5

attachToTargetMethod · 0.80
infoMethod · 0.65
enableMethod · 0.65
onMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected