| 325 | } |
| 326 | |
| 327 | async close(): Promise<void> { |
| 328 | this._closing = true |
| 329 | |
| 330 | this._crawlEndFinder.cancel() |
| 331 | await Promise.allSettled([ |
| 332 | this.pluginContainer.close(), |
| 333 | this.bundledDev?.close(), |
| 334 | this.depsOptimizer?.close(), |
| 335 | // WebSocketServer is independent of HotChannel and should not be closed on environment close |
| 336 | isWebSocketServer in this.hot ? Promise.resolve() : this.hot.close(), |
| 337 | (async () => { |
| 338 | while (this._pendingRequests.size > 0) { |
| 339 | await Promise.allSettled( |
| 340 | [...this._pendingRequests.values()].map( |
| 341 | (pending) => pending.request, |
| 342 | ), |
| 343 | ) |
| 344 | } |
| 345 | })(), |
| 346 | ]) |
| 347 | } |
| 348 | |
| 349 | /** |
| 350 | * Calling `await environment.waitForRequestsIdle(id)` will wait until all static imports |