Skip to main content

Logout

Ends the Instagram session and cleans up resources. This node should be called when you're finished using Instagram operations to properly release the session.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • Session ID - The session identifier returned from the Login node. This identifies which session to close.

Output

  • Success - Boolean value indicating whether the logout was successful (true) or not (false).

How It Works

The Logout node properly terminates an Instagram session and releases associated resources. When executed, it:

  1. Validates that a Session ID is provided
  2. Retrieves the Instaloader instance associated with the session
  3. Calls the close method to properly terminate the connection
  4. Removes the session from the internal registry
  5. Returns a success status

Even if the close operation fails, the session is removed from the registry to prevent resource leaks.

Requirements

  • A valid Session ID from a previous Login operation
  • The session should still be active (not already logged out)

Error Handling

The node will return specific errors in the following cases:

  • ErrInvalidArg - Session ID is missing or empty

Common Errors

Missing Session ID:

Session ID is required

Solution: Ensure you're passing the Session ID from the Login node.

Usage Notes

  • Always call Logout at the end of your Instagram workflow to clean up resources
  • The Logout operation is safe to call multiple times on the same session
  • Even if an error occurred during your workflow, call Logout in a finally block
  • Logging out does not delete saved session files; it only cleans up in-memory resources
  • After logout, the Session ID becomes invalid and cannot be reused

Example: Basic Workflow

Flow:

Login
↓ (Session ID)
Get Profile Info
↓ (Session ID)
Get Profile Posts
↓ (Session ID)
Logout

Logout Node Configuration:

  • Session ID: msg.instagram_session_id (from Login node)

Result:

  • Success: true
  • Session resources cleaned up

Example: Error Handling with Logout

Flow with Try-Catch:

Try
├─ Login → Store Session ID
├─ Get Profile Info
├─ Get Profile Posts
└─ (Success path) → Logout
Catch
└─ (Error path) → Logout

This ensures Logout is called whether the workflow succeeds or fails.

Best Practices

  • Always pair Login with Logout to prevent resource leaks
  • Use try-catch-finally patterns to ensure Logout is called even when errors occur
  • Call Logout once per Login, typically at the end of your workflow
  • Don't reuse a Session ID after calling Logout
  • For long-running workflows, logout and login again periodically to refresh the session
  • Clean up session files separately if needed (Logout doesn't delete files)

Tips for Effective Use

  • Resource Management: Logout releases memory and network resources associated with the session
  • Multiple Accounts: When working with multiple Instagram accounts, track Session IDs separately and logout each one
  • Workflow Design: Place Logout in a dedicated cleanup section of your flow
  • Testing: During development, always test that Logout is called in both success and failure scenarios
  • Performance: While Logout is quick, it's still important for preventing resource exhaustion in long-running automations

Common Patterns

Pattern 1: Simple Workflow

Login → Operations → Logout

Pattern 2: With Error Handling

Login → Try { Operations } Finally { Logout }

Pattern 3: Multiple Sessions

Login (Account A) → Session ID A
Login (Account B) → Session ID B
Operations with both accounts
Logout (Session A)
Logout (Session B)