Skip to content

fix(sap): heartbeat script to keep the self-hosted VM session logged in - #453

Open
HappyDevs1 wants to merge 1 commit into
mainfrom
fix/sap-idle-timeout-keep-alive
Open

fix(sap): heartbeat script to keep the self-hosted VM session logged in#453
HappyDevs1 wants to merge 1 commit into
mainfrom
fix/sap-idle-timeout-keep-alive

Conversation

@HappyDevs1

@HappyDevs1 HappyDevs1 commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #438. The SAP GUI session kept logged in on our self-hosted VM
periodically hits "Maximum idle time exceeded" between a human's
interactive record/run sessions, and nobody notices until the next
flow fails.

connect() already auto-logs in whenever it finds a session sitting at
SAP's login screen (SAP_USER/SAP_PASSWORD, see #226 / 0e32af0), and
the nightly sap-e2e.yml workflow already benefits from this on every
scheduled run. The actual gap is that nothing triggers an attach on a
timer between runs on the VM outside CI, so that self-healing path
never fires until someone happens to run a flow.

  • scripts/sap-keep-alive.ps1 (new): bootstraps the session (reusing
    sap-session-bootstrap.ps1) and attaches via the existing
    examples/sap/session-status.flow.yaml no-op ping, logging one line
    per run to %LOCALAPPDATA%\flowproof\keep-alive.log. Meant to be
    registered as a Windows Scheduled Task, e.g. every 5-10 minutes.
  • No Rust changes — this only schedules an already-tested recovery path.

Follow-up outside this repo

Raising the SAP-side idle-timeout profile parameter
(rdisp/gui_auto_logout or equivalent) for this technical/service user
would reduce how often this triggers at all. Flagging for whoever owns
SAP Basis; not blocking this PR on it.

Test plan

  • [System.Management.Automation.Language.Parser]::ParseFile(...)
    confirms the script has no syntax errors
  • Register as a Scheduled Task on the VM and confirm
    keep-alive.log picks up a success line on schedule
  • Manually log the persistent session out and confirm the next
    scheduled run self-heals it (auto-login + ping passes)

🤖 Generated with Claude Code

connect() already auto-logs in when it finds a session sitting at SAP's
login screen (see #226 / 0e32af0), and the nightly sap-e2e workflow
already benefits from that on every scheduled run. Nothing, however,
touches the session between a human's interactive record/run sessions on
the same VM - it idles out ("Maximum idle time exceeded", #438) and the
first anyone learns of it is a failed flow.

sap-keep-alive.ps1 triggers the existing auto-login path on a timer: it
bootstraps the session (reusing sap-session-bootstrap.ps1) and attaches
via the existing no-op session-status ping flow, logging one line per
run so "when did this last succeed" doesn't require Task Scheduler's
own history UI. Meant to be registered as a Windows Scheduled Task.

No Rust changes - this only schedules an already-tested recovery path.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@HappyDevs1
HappyDevs1 marked this pull request as ready for review August 7, 2026 15:06
Copilot AI review requested due to automatic review settings August 7, 2026 15:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a Windows Scheduled Task–friendly heartbeat script to periodically attach to the long-lived SAP GUI session on the self-hosted VM, ensuring the existing connect() auto-login/self-healing path gets exercised before a human-triggered record/run fails due to SAP idle timeout.

Changes:

  • Add scripts/sap-keep-alive.ps1 to bootstrap SAP Logon and run the existing examples/sap/session-status.flow.yaml “ping” flow on a timer.
  • Append timestamped success/failure lines to %LOCALAPPDATA%\flowproof\keep-alive.log and exit non-zero on failures for Task Scheduler visibility.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

try {
& (Join-Path $PSScriptRoot 'sap-session-bootstrap.ps1')

$output = & npx flowproof run $pingFlow 2>&1
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.

SAP GUI session times out with 'Maximum idle time exceeded' on self-hosted VM

2 participants