| 1 | --- |
| 2 | title: "htmx:finally:request" |
| 3 | description: "At the end of request lifecycle" |
| 4 | --- |
| 5 | |
| 6 | The `htmx:finally:request` event fires at the very end of the request cycle, whether successful or failed. |
| 7 | |
| 8 | ## When It Fires |
| 9 | |
| 10 | After all request processing completes, similar to a `finally` block in try/catch. |
| 11 | |
| 12 | ## Event Detail |
| 13 | |
| 14 | - `ctx` - Request context object |
| 15 | |
| 16 | ## Example |
| 17 | |
| 18 | ```javascript |
| 19 | htmx.on('htmx:finally:request', (evt) => { |
| 20 | console.log('Request complete:', evt.detail.ctx); |
| 21 | // Always hide loading indicator, clean up resources |
| 22 | }); |
| 23 | ``` |
| 24 | |
| 25 | Useful for cleanup operations that should always run regardless of success or failure. |