Skip to content

Smarter Async Execution: Context-Aware Queueable Invocation #15

@Mateusz7410

Description

@Mateusz7410

Motivation

Queueables are often created only to enter an async context. When code is already running asynchronously, enqueuing another Queueable is frequently unnecessary and leads to overuse of async jobs, added complexity, and avoidable governor pressure.

Proposed Idea

Introduce a context-aware async execution strategy where business logic can:
• Execute immediately if already in an async context, or
• Enqueue a Queueable only when needed.

The Queueable itself should be lightweight and act only as an entry point to the business logic.

Decision Logic

Execution behavior could be determined by:
• Current execution context (sync vs async)
• Governor limits (e.g. CPU usage)
• Configurable defaults via Custom Metadata

Callers could override behavior per use case:
• Always async
• Force immediate execution
• Let the framework decide (similar to Flow’s “Let the flow decide”)

Benefits

•	Reduced Queueable overuse
•	Better async efficiency and limit utilization
•	Less reliance on async exception-handling patterns

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions