# Environment Variables That Control Session Timeout and Tab Inactivity in Camofox-Browser

> Discover how to control Camofox-Browser session timeout and tab inactivity using SESSION_TIMEOUT_MS and TAB_INACTIVITY_MS environment variables. Customize your browsing experience now.

- Repository: [jo/camofox-browser](https://github.com/jo-inc/camofox-browser)
- Tags: api-reference
- Published: 2026-04-15

---

**The `SESSION_TIMEOUT_MS` and `TAB_INACTIVITY_MS` environment variables in [`lib/config.js`](https://github.com/jo-inc/camofox-browser/blob/main/lib/config.js) govern how long user sessions and idle browser tabs persist before automatic cleanup, defaulting to 600000ms (10 minutes) and 300000ms (5 minutes) respectively.**

Camofox-browser, an open-source remote browser solution maintained by `jo-inc`, centralizes all environment-dependent configuration in a single module. Operators can fine-tune resource consumption and session lifecycle by adjusting two specific variables that control maximum session lifetime and tab inactivity thresholds. These settings are parsed at startup from `process.env` and consumed throughout the application to manage memory and connection cleanup.

## Configuration File Location

All environment variable reads for timeout behavior reside in **[`lib/config.js`](https://github.com/jo-inc/camofox-browser/blob/main/lib/config.js)**. This file acts as the single source of truth for runtime constants, preventing scattered `process.env` calls across the codebase.

At lines 51 and 52, the configuration object reads the two critical variables using `parseInt` with fallback defaults:

```javascript
// lib/config.js (excerpt)
sessionTimeoutMs: parseInt(process.env.SESSION_TIMEOUT_MS) || 600000,
tabInactivityMs:   parseInt(process.env.TAB_INACTIVITY_MS)   || 300000,

```

If the environment variables are undefined, the server uses the hardcoded defaults shown above.

## Session and Tab Timeout Variables

### SESSION_TIMEOUT_MS

The **`SESSION_TIMEOUT_MS`** variable defines the maximum lifetime of a user session in milliseconds. When this threshold elapses, the server removes the session entirely, releasing associated tabs, cookies, and memory.

- **Default value:** `600000` (10 minutes)
- **Source location:** [[`lib/config.js`](https://github.com/jo-inc/camofox-browser/blob/main/lib/config.js) line 51](https://github.com/jo-inc/camofox-browser/blob/master/lib/config.js#L51)
- **Effect:** Forces session cleanup regardless of activity level

### TAB_INACTIVITY_MS

The **`TAB_INACTIVITY_MS`** variable specifies how long a browser tab can remain idle—meaning no navigation or user interaction—before the server terminates it.

- **Default value:** `300000` (5 minutes)
- **Source location:** [[`lib/config.js`](https://github.com/jo-inc/camofox-browser/blob/main/lib/config.js) line 52](https://github.com/jo-inc/camofox-browser/blob/master/lib/config.js#L52)
- **Effect:** Closes individual tabs that exceed the inactivity threshold while keeping the broader session alive

## Practical Configuration Examples

You can override these defaults through several methods before launching the server.

### Shell Environment Export

Set the variables in your Unix-style shell to adjust timeouts for the current session:

```bash
export SESSION_TIMEOUT_MS=1200000   # 20 minutes

export TAB_INACTIVITY_MS=180000     # 3 minutes

npm start

```

This approach works for containerized deployments where you inject environment variables at runtime.

### Dotenv File Configuration

Camofox-browser supports environment files through `dotenv` integration in its start script. Create a `.env` file in the project root:

```ini

# .env

SESSION_TIMEOUT_MS=900000   # 15 minutes

TAB_INACTIVITY_MS=240000    # 4 minutes

```

The application loads these values automatically when starting, making this ideal for development environments.

### Programmatic Verification

To confirm the configuration loaded correctly during testing or debugging, require the config module directly:

```javascript
const config = require('./lib/config');

console.log('Session timeout (ms):', config.sessionTimeoutMs);
console.log('Tab inactivity (ms):', config.tabInactivityMs);

```

## Integration with Server Logic

The timeout values defined in [`lib/config.js`](https://github.com/jo-inc/camofox-browser/blob/main/lib/config.js) propagate to **[`server.js`](https://github.com/jo-inc/camofox-browser/blob/main/server.js)**, where Express routes create and manage browser sessions. The server uses these millisecond values to schedule cleanup intervals and check idle states when determining whether to terminate tabs or expire sessions.

According to the source code in `jo-inc/camofox-browser`, separating configuration from logic allows operators to tune resource usage for specific deployment scenarios—such as extending session durations for trusted internal networks or shortening tab lifetimes on resource-constrained servers—without modifying application code.

## Summary

- **`SESSION_TIMEOUT_MS`** controls total session lifetime, defaulting to 10 minutes (600000ms) when unset.
- **`TAB_INACTIVITY_MS`** controls individual tab idle time, defaulting to 5 minutes (300000ms).
- Both variables are defined in [`lib/config.js`](https://github.com/jo-inc/camofox-browser/blob/main/lib/config.js) at lines 51 and 52, parsed via `parseInt(process.env.VARNAME)` with logical OR fallbacks.
- Configuration can be injected via shell exports, `.env` files, or container orchestration environment blocks.
- Changes take effect immediately at server startup and apply to all subsequently created sessions.

## Frequently Asked Questions

### What happens if I set SESSION_TIMEOUT_MS to 0?

Setting `SESSION_TIMEOUT_MS` to 0 or a non-numeric string causes `parseInt` to return `NaN`, which evaluates as falsy in JavaScript. Consequently, the application falls back to the default value of 600000ms (10 minutes). To disable session timeouts entirely, you would need to modify the source logic, as the current implementation always enforces a cleanup interval.

### Can I use different timeouts for specific users or endpoints?

The current implementation in `jo-inc/camofox-browser` applies these timeouts globally through the shared configuration object. Per-user or per-endpoint timeout customization would require modifying [`server.js`](https://github.com/jo-inc/camofox-browser/blob/main/server.js) to accept override parameters during session creation, as the static values in [`lib/config.js`](https://github.com/jo-inc/camofox-browser/blob/main/lib/config.js) apply universally to all sessions and tabs.

### How do these variables interact with each other?

`SESSION_TIMEOUT_MS` acts as the absolute ceiling for a user's total connection time, while `TAB_INACTIVITY_MS` manages individual tab lifecycle within that session. A session can persist even if individual tabs are closed due to inactivity, but once the session timeout elapses, all remaining tabs are terminated regardless of their individual activity status.

### Where should I report issues if the environment variables are not recognized?

First verify that the variables are exported before the Node.js process starts and that you are using the variable names exactly as defined in [`lib/config.js`](https://github.com/jo-inc/camofox-browser/blob/main/lib/config.js): uppercase with `_MS` suffix. If variables are set but ignored, check the startup logs and confirm the `dotenv` package loaded correctly, then open an issue in the `jo-inc/camofox-browser` repository referencing your [`lib/config.js`](https://github.com/jo-inc/camofox-browser/blob/main/lib/config.js) line numbers.