Skip to content

Commit 970dc55

Browse files
committed
await session cleanup
1 parent f7f4885 commit 970dc55

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@
2828
"prettier:check": "prettier --check .",
2929
"prettier:fix": "prettier --write .",
3030
"clean": "rm -rf dist",
31-
"prepublishOnly": "pnpm clean && pnpm build"
31+
"prepublishOnly": "pnpm clean && pnpm build",
32+
"test": "bash tests/run-tests.sh",
33+
"test:minimal": "bash tests/run-tests.sh --type minimal",
34+
"test:advanced": "bash tests/run-tests.sh --type advanced --llm",
35+
"test:all": "bash tests/run-tests.sh --type all",
36+
"test:debug": "bash tests/run-tests.sh --debug",
37+
"test:install": "npm install @mcpvals chalk",
38+
"test:runner": "tsx tests/run-evals.ts"
3239
},
3340
"lint-staged": {
3441
"*.{js,jsx,ts,tsx,json,css,scss,md}": [
@@ -47,6 +54,8 @@
4754
},
4855
"devDependencies": {
4956
"@eslint/js": "^9.29.0",
57+
"@mcpvals": "^0.1.0",
58+
"chalk": "^5.3.0",
5059
"eslint": "^9.29.0",
5160
"eslint-plugin-react": "^7.37.5",
5261
"globals": "^16.2.0",

src/sessionManager.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,15 @@ export async function getSession(
324324
* This is called after a browser is closed to ensure proper cleanup.
325325
* @param sessionId The session ID to clean up
326326
*/
327-
export function cleanupSession(sessionId: string): void {
327+
export async function cleanupSession(sessionId: string): Promise<void> {
328328
process.stderr.write(`[SessionManager] Cleaning up session: ${sessionId}\n`);
329329

330+
// Get the session to close it gracefully
331+
const session = browsers.get(sessionId);
332+
if (session) {
333+
await closeBrowserGracefully(session, sessionId);
334+
}
335+
330336
// Remove from browsers map
331337
browsers.delete(sessionId);
332338

src/tools/session.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ async function handleCloseSession(context: Context): Promise<ToolResult> {
161161
);
162162

163163
// Clean up the session from tracking
164-
cleanupSession(previousSessionId);
164+
await cleanupSession(previousSessionId);
165165

166166
if (browserbaseSessionId) {
167167
process.stderr.write(

0 commit comments

Comments
 (0)