Skip to content

Conversation

@NewtonDer
Copy link
Contributor

@NewtonDer NewtonDer commented Dec 5, 2025

Issue

Description of Changes

Problem:
If user starts a process in the Terminal and closes the browser tab, the SageMaker Code Editor space will still automatically shut down after the idle timeout.

Explanation:
The sagemaker-idle-extension's checkTerminalActivity method halts when the browser tab is closed. Thus, it is unable to detect any running processes and avoid the idle timeout.

Solution:
Moves sagemaker-idle-extension's checkTerminalActivity method to server side in webClientServer. This method is called in the /api/idle handler, which currently happens on a 1 minute interval.

Testing

Tested with a custom image deployed in a SageMaker AI Studio domain.

Screenshots/Videos

Additional Notes

This same fix is already launched and working in sagemaker-code-editor versions 1.5, 1.6, and 1.7.

Backporting


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@NewtonDer NewtonDer requested review from a team as code owners December 5, 2025 20:32
@NewtonDer NewtonDer changed the title [WIP] Fix idle shutdown from happening when active process is still running Fix idle shutdown from happening when active process is still running Dec 5, 2025

import { createReadStream, promises, existsSync, writeFileSync } from 'fs';
import * as http from 'http';
+import { spawn } from 'child_process';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build fails without this line (The exact build error: Error: /home/ubuntu/environment/code-editor/code-editor-src/src/vs/server/node/webClientServer.ts(602,25): Cannot find name 'spawn'.).

I added back this line when testing for the build to be successful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@vpaiu
Copy link
Contributor

vpaiu commented Dec 8, 2025

After I fixed locally the build error I did the following to test the idle-extension:

  1. Created the sagemaker image with the build artifact.
  2. Created the sagemaker code editor space in SageMaker Unified Studio with the image created.
  3. Tested that the timestamp is updated properly by executing cat /tmp/.sagemaker-last-active-timestamp in the terminal in the code editor space. It printed the expected timestamp.
  4. Tested that the api edpoint (/api/idle/) was returning the correct timestamp. I did this by executing fetch(window.location.pathname + '/api/idle').then(r => r.json()).then(console.log) in the web developer tools console. It returned the correct timestamp.

@NewtonDer NewtonDer merged commit aa90c70 into aws:main Dec 9, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants