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

Method getScriptByIdOrWait

valdi/vscode_debugger/src/adapter/threads.ts:775–788  ·  view source on GitHub ↗

* Gets a script ID if it exists, or waits to up maxTime. In rare cases we * can get a request (like a stacktrace request) from DAP before Chrome * finishes passing its sources over. We *should* normally know about all * possible script IDs; this waits if we see one that we don't.

(scriptId: string, maxTime = 500)

Source from the content-addressed store, hash-verified

773 * possible script IDs; this waits if we see one that we don't.
774 */
775 private async getScriptByIdOrWait(scriptId: string, maxTime = 500) {
776 let script = this._sourceContainer.scriptsById.get(scriptId);
777 if (script) {
778 return script;
779 }
780
781 const deadline = Date.now() + maxTime;
782 do {
783 await delay(50);
784 script = this._sourceContainer.scriptsById.get(scriptId);
785 } while (!script && Date.now() < deadline);
786
787 return script;
788 }
789
790 async renderDebuggerLocation(loc: Cdp.Debugger.Location): Promise<string> {
791 const raw = this.rawLocation(loc);

Callers 1

Calls 3

delayFunction · 0.90
getMethod · 0.65
nowMethod · 0.65

Tested by

no test coverage detected