This rule disallows calling await handle.result() inside the run or onSuccess functions. Awaiting a background action result in these contexts causes significant problems:
- In
run: Blocks the transaction and can cause GGT_TRANSACTION_TIMEOUT errors
- In
onSuccess: Bills for the full wait time of the background action
Rule Details
This rule detects await handle.result() calls directly inside run or onSuccess exports (not in nested callbacks or helper functions) and reports them with context-specific error messages.
Severity: Warning
Auto-fixable: No
Examples
Incorrect
Correct
Why This Is a Problem
In run functions
Model action run functions execute inside a database transaction by default. Awaiting a background job result blocks the transaction for the entire duration of the background job, which can easily exceed the 5-second transaction timeout limit.
In onSuccess functions
Awaiting a background job in onSuccess keeps the action running and bills you for the entire wait time, even though you could poll for the result from the frontend instead.
Recommended Patterns
Store the handle ID and poll from frontend
Use a separate polling action
This rule helps prevent costly mistakes. Always store background job handles and poll for results outside of transactional contexts.
When to Use
This rule is included in the recommended config and should always be enabled for Gadget projects. It prevents performance problems and unexpected timeouts.