MCPcopy Create free account
hub / github.com/cloudflare/computer / close

Method close

packages/computer/src/workspace.ts:773–796  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

771 }
772
773 async close(): Promise<void> {
774 // Close every cached handle in parallel. Drop caches before
775 // awaiting so a subsequent ready() / exec sees an empty slate
776 // and rebuilds against fresh handles.
777 this.#connectionGeneration += 1;
778 const handles = [...this.#handles.values()];
779 const moduleHandles = [...this.#moduleHandles.values()];
780 this.#handles.clear();
781 this.#shells.clear();
782 this.#connecting.clear();
783 this.#moduleHandles.clear();
784 this.#connectingModuleHandles.clear();
785 this.#readyPromise = undefined;
786 await Promise.all(
787 [...handles, ...moduleHandles].map(async (h) => {
788 try {
789 await h.close();
790 } catch {
791 // close() is best-effort; a transport that's already
792 // gone shouldn't take the workspace down with it.
793 }
794 }),
795 );
796 }
797
798 #moduleHandleFor(id: string): Promise<WorkspaceModuleBackendHandle> {
799 const cached = this.#moduleHandles.get(id);

Callers 2

withStubFunction · 0.95
withWorkspaceFunction · 0.95

Calls 4

allMethod · 0.80
valuesMethod · 0.65
clearMethod · 0.65
closeMethod · 0.65

Tested by 1

withStubFunction · 0.76