Plugins
Plugin order
Learn the order plugins run in, and why logger, retry, timeout and bearer go in that order.
The order of a client's plugins list decides what each plugin sees. This
page explains how plugins nest, and why the order used in
Built-in plugins is the one to use.
How plugins nest
The first plugin is the outermost: it runs first on the way out, and last on the way back.
The recommended order
List the built-in plugins as logger, retry, timeout, bearer, as in
the example in Built-in plugins. With that order:
loggersees the whole call, retries included (consoleLoggersees the whole call wherever it is);- each retry gets its own timeout, and asks for the token again;
- a timed-out attempt isn't retried;
retry'sbudgetcovers every attempt and wait, whiletimeoutcovers one attempt;- a
401thatbearerrefreshes is sent again inside the same attempt, so it shares that attempt's timeout.
For when each hook runs in that order, see the hooks table in Write a plugin.