diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index 38ebe1403..27c0e9cb2 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -477,6 +477,21 @@ export default class Explorer { }, body: JSON.stringify(provisionData) }) + const websocketId = await response.text(); + const unprovisionData = { + resourceId: userContext.databaseAccount.id, + websocketId: websocketId + } + + window.addEventListener("beforeunload", async () => { + const response = await window.fetch("http://localhost:443/api/containerpooling/unprovision", { + method: "POST", + headers: { + [HttpHeaders.contentType]: "application/json", + }, + body: JSON.stringify(unprovisionData) + }) + }) this.notebookServerInfo({ notebookServerEndpoint: userContext.features.notebookServerUrl || `http://localhost:443/api/containerpooling/resid${userContext.databaseAccount.id}/forward/`,