Stop paying for browser sessions you forgot to close

By General Input

Every evening, find the cloud browsers left running by crashed or half-finished jobs, shut them down, and post the count to Slack.

Integrations

  • Kernel
  • Google Sheets
  • Slack

Type

Deterministic Code

Categories

  • Engineering
  • Operations

Every day at 6pm, on a cron trigger, sweep my Kernel account for browser sessions that were left running and reclaim them before they cost me money and block new work. This is a fully deterministic workflow: list, filter by age, delete, log, format, post. There is no judgement step anywhere, so build it as a code workflow.

Start by calling Kernel's List Browser Sessions, filtered to running sessions. Page through the results rather than reading only the first page, so an account with many sessions is fully covered.

For each running session, work out its age by comparing its creation timestamp to the current time. If a session is older than the age threshold, which should default to 60 minutes and be exposed as a configurable value, call Delete Browser Session for that session id. Leave anything younger than the threshold alone, since those are most likely legitimate in-flight runs.

For every session reclaimed, append one row to a Google Sheets audit log using Append Values. Each row should carry the session id, the session name, the age at reclaim in minutes, and the timestamp of the sweep. Append to the same tab every night so the log accumulates. This log is the point of the workflow as much as the deletions are: it is what lets someone notice that one particular job leaks a session every single night, which is the actual root cause worth fixing.

Finish by sending a Slack message with Send a Message to a configured channel, containing three numbers: how many sessions are still running after the sweep, how many were reclaimed, and how many were swept in total. Post this message on every run, including clean runs where nothing was reclaimed, so the team can see the sweep is alive rather than silently broken.

Keep the age threshold and the Slack channel as the two obvious knobs to change, defined clearly at the top of the workflow. The target spreadsheet and tab for the audit log should be configurable too. If a delete call fails for one session, log it and carry on with the rest rather than aborting the whole sweep, and reflect the failure in the counts.

Related prompts

Explore more prompts
Call overdue Xero customers with an AI collections agentLocal listing health board for every location you manageWin back LiveChat visitors whose chats went unansweredLet support send one-off Loops emails without an engineerStop cold emails to anyone with a live deal in PipedriveiMessage campaign console with pre-flight checks and delivery boardChat quality review board for LiveChat support leadsLinkedIn Ads budget pacing dashboard for every client accountFront desk appointment confirmation board for the next 3 daysGive your team Looker numbers without buying more seats