Skip to content

Commit 6a5d157

Browse files
committed
stop/webhook and close app socket on stop app
1 parent 9d846ee commit 6a5d157

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

augmentos_cloud/packages/cloud/src/services/core/app.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export class AppService {
219219
data: WebhookResponse;
220220
}> {
221221
// Construct the stop webhook URL from the app's public URL
222-
const webhookUrl = `${publicUrl}/webhook/stop`;
222+
const webhookUrl = `${publicUrl}/webhook`;
223223
const response = await axios.post(webhookUrl, payload);
224224
return {
225225
status: response.status,

augmentos_cloud/packages/cloud/src/services/core/websocket.service.ts

+15-6
Original file line numberDiff line numberDiff line change
@@ -537,15 +537,13 @@ export class WebSocketService {
537537
(appName) => appName !== packageName
538538
);
539539

540-
// Optional: Trigger stop webhook if needed
541-
// Uncomment this if you want to implement stop webhook calls
542-
/*
540+
543541
try {
544542
const tpaSessionId = `${userSession.sessionId}-${packageName}`;
545-
await this.appService.triggerStopWebhook(
543+
await appService.triggerStopWebhook(
546544
app.publicUrl,
547545
{
548-
type: 'stop_request',
546+
type: WebhookRequestType.STOP_REQUEST,
549547
sessionId: tpaSessionId,
550548
userId: userSession.userId,
551549
reason: 'user_disabled',
@@ -556,7 +554,18 @@ export class WebSocketService {
556554
userSession.logger.error(`Error calling stop webhook for ${packageName}:`, error);
557555
// Continue with cleanup even if webhook fails
558556
}
559-
*/
557+
558+
// End the websocket connection for the app
559+
try {
560+
const websocket = userSession.appConnections.get(packageName);
561+
if (websocket && websocket.readyState === WebSocket.OPEN) {
562+
websocket.close();
563+
userSession.appConnections.delete(packageName);
564+
}
565+
} catch (error) {
566+
userSession.logger.error(`Error ending websocket for TPA ${packageName}:`, error);
567+
// Continue with cleanup even if webhook fails
568+
}
560569

561570
// Update user's running apps in database
562571
try {

0 commit comments

Comments
 (0)