()
| 121 | } |
| 122 | |
| 123 | async disposeAll(): Promise<void> { |
| 124 | const sessions = Array.from(this.sessions.values()); |
| 125 | this.sessions.clear(); |
| 126 | this.currentSessionId = null; |
| 127 | |
| 128 | const runWithTimeout = async ( |
| 129 | operation: () => Promise<void>, |
| 130 | timeoutMs: number, |
| 131 | ): Promise<void> => { |
| 132 | const timeoutPromise = new Promise<'timed_out'>((resolve) => { |
| 133 | const timer = setTimeout(() => resolve('timed_out'), timeoutMs); |
| 134 | timer.unref?.(); |
| 135 | }); |
| 136 | |
| 137 | await Promise.race([ |
| 138 | operation() |
| 139 | .then(() => 'completed' as const) |
| 140 | .catch(() => 'failed' as const), |
| 141 | timeoutPromise, |
| 142 | ]); |
| 143 | }; |
| 144 | |
| 145 | await Promise.allSettled( |
| 146 | sessions.map(async (session) => { |
| 147 | try { |
| 148 | await runWithTimeout(() => session.backend.detach(), 1000); |
| 149 | } finally { |
| 150 | await runWithTimeout(() => session.backend.dispose(), 1000); |
| 151 | session.releaseActivity(); |
| 152 | } |
| 153 | }), |
| 154 | ); |
| 155 | } |
| 156 | |
| 157 | async addBreakpoint( |
| 158 | id: string | undefined, |
no test coverage detected