Skip to content

Fallback

This page explains various techniques for handling failures and creating fallback mechanisms in the Effect library.

We can attempt one effect, and if it fails, we can try another effect using the Effect.orElse function.

Example

1
import {
import Effect
Effect
} from "effect"
2
3
const
const success: Effect.Effect<string, never, never>
success
=
import Effect
Effect
.
const succeed: <string>(value: string) => Effect.Effect<string, never, never>
succeed
("success")
4
const
const failure: Effect.Effect<never, string, never>
failure
=
import Effect
Effect
.
const fail: <string>(error: string) => Effect.Effect<never, string, never>
fail
("failure")
5
const
const fallback: Effect.Effect<string, never, never>
fallback
=
import Effect
Effect
.
const succeed: <string>(value: string) => Effect.Effect<string, never, never>
succeed
("fallback")
6
7
const
const program1: Effect.Effect<string, never, never>
program1
=
import Effect
Effect
.
const orElse: <string, never, never, string, never, never>(self: Effect.Effect<string, never, never>, that: LazyArg<Effect.Effect<string, never, never>>) => Effect.Effect<string, never, never> (+1 overload)

Executes this effect and returns its value, if it succeeds, but otherwise executes the specified effect.

orElse
(
const success: Effect.Effect<string, never, never>
success
, () =>
const fallback: Effect.Effect<string, never, never>
fallback
)
8
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
import Effect
Effect
.
const runSync: <string, never>(effect: Effect.Effect<string, never, never>) => string
runSync
(
const program1: Effect.Effect<string, never, never>
program1
))
9
// Output: "success"
10
11
const
const program2: Effect.Effect<string, never, never>
program2
=
import Effect
Effect
.
const orElse: <never, string, never, string, never, never>(self: Effect.Effect<never, string, never>, that: LazyArg<Effect.Effect<string, never, never>>) => Effect.Effect<string, never, never> (+1 overload)

Executes this effect and returns its value, if it succeeds, but otherwise executes the specified effect.

orElse
(
const failure: Effect.Effect<never, string, never>
failure
, () =>
const fallback: Effect.Effect<string, never, never>
fallback
)
12
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
import Effect
Effect
.
const runSync: <string, never>(effect: Effect.Effect<string, never, never>) => string
runSync
(
const program2: Effect.Effect<string, never, never>
program2
))
13
// Output: "fallback"

These two operators modify the original failure by replacing it with constant succeed or failure values.

The Effect.orElseFail will always replace the original failure with the new one:

1
import {
import Effect
Effect
} from "effect"
2
3
const
const validate: (age: number) => Effect.Effect<number, string>
validate
= (
(parameter) age: number
age
: number):
import Effect
Effect
.
interface Effect<out A, out E = never, out R = never> namespace Effect

The `Effect` interface defines a value that lazily describes a workflow or job. The workflow requires some context `R`, and may fail with an error of type `E`, or succeed with a value of type `A`. `Effect` values model resourceful interaction with the outside world, including synchronous, asynchronous, concurrent, and parallel interaction. They use a fiber-based concurrency model, with built-in support for scheduling, fine-grained interruption, structured concurrency, and high scalability. To run an `Effect` value, you need a `Runtime`, which is a type that is capable of executing `Effect` values.

Effect
<number, string> => {
4
if (
(parameter) age: number
age
< 0) {
5
return
import Effect
Effect
.
const fail: <string>(error: string) => Effect.Effect<never, string, never>
fail
("NegativeAgeError")
6
} else if (
(parameter) age: number
age
< 18) {
7
return
import Effect
Effect
.
const fail: <string>(error: string) => Effect.Effect<never, string, never>
fail
("IllegalAgeError")
8
} else {
9
return
import Effect
Effect
.
const succeed: <number>(value: number) => Effect.Effect<number, never, never>
succeed
(
(parameter) age: number
age
)
10
}
11
}
12
13
const
const program: Effect.Effect<number, string, never>
program
=
import Effect
Effect
.
const orElseFail: <number, string, never, string>(self: Effect.Effect<number, string, never>, evaluate: LazyArg<string>) => Effect.Effect<number, string, never> (+1 overload)

Executes this effect and returns its value, if it succeeds, but otherwise fails with the specified error.

orElseFail
(
const validate: (age: number) => Effect.Effect<number, string>
validate
(-1), () => "invalid age")
14
15
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
import Effect
Effect
.
const runSyncExit: <number, string>(effect: Effect.Effect<number, string, never>) => Exit<number, string>
runSyncExit
(
const program: Effect.Effect<number, string, never>
program
))
16
/*
17
Output:
18
{
19
_id: 'Exit',
20
_tag: 'Failure',
21
cause: { _id: 'Cause', _tag: 'Fail', failure: 'invalid age' }
22
}
23
*/

The Effect.orElseSucceed function will always replace the original failure with a success value, so the resulting effect cannot fail:

1
import {
import Effect
Effect
} from "effect"
2
3
const
const validate: (age: number) => Effect.Effect<number, string>
validate
= (
(parameter) age: number
age
: number):
import Effect
Effect
.
interface Effect<out A, out E = never, out R = never> namespace Effect

The `Effect` interface defines a value that lazily describes a workflow or job. The workflow requires some context `R`, and may fail with an error of type `E`, or succeed with a value of type `A`. `Effect` values model resourceful interaction with the outside world, including synchronous, asynchronous, concurrent, and parallel interaction. They use a fiber-based concurrency model, with built-in support for scheduling, fine-grained interruption, structured concurrency, and high scalability. To run an `Effect` value, you need a `Runtime`, which is a type that is capable of executing `Effect` values.

Effect
<number, string> => {
4
if (
(parameter) age: number
age
< 0) {
5
return
import Effect
Effect
.
const fail: <string>(error: string) => Effect.Effect<never, string, never>
fail
("NegativeAgeError")
6
} else if (
(parameter) age: number
age
< 18) {
7
return
import Effect
Effect
.
const fail: <string>(error: string) => Effect.Effect<never, string, never>
fail
("IllegalAgeError")
8
} else {
9
return
import Effect
Effect
.
const succeed: <number>(value: number) => Effect.Effect<number, never, never>
succeed
(
(parameter) age: number
age
)
10
}
11
}
12
13
const
const program: Effect.Effect<number, never, never>
program
=
import Effect
Effect
.
const orElseSucceed: <number, string, never, number>(self: Effect.Effect<number, string, never>, evaluate: LazyArg<number>) => Effect.Effect<number, never, never> (+1 overload)

Executes this effect and returns its value, if it succeeds, but otherwise succeeds with the specified value.

orElseSucceed
(
const validate: (age: number) => Effect.Effect<number, string>
validate
(-1), () => 18)
14
15
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
import Effect
Effect
.
const runSyncExit: <number, never>(effect: Effect.Effect<number, never, never>) => Exit<number, never>
runSyncExit
(
const program: Effect.Effect<number, never, never>
program
))
16
/*
17
Output:
18
{ _id: 'Exit', _tag: 'Success', value: 18 }
19
*/

The Effect.firstSuccessOf function simplifies running a series of effects and returns the result of the first one that succeeds. If none of the effects succeed, the resulting effect will fail with the error of the last effect in the series.

Example

In the following example, we attempt to retrieve a configuration from different nodes. If retrieving from the primary node fails, we successively try retrieving from the next available nodes until we find a successful result.

1
import {
import Effect
Effect
,
import Console
Console
} from "effect"
2
3
interface
interface Config
Config
{
4
(property) Config.host: string
host
: string
5
(property) Config.port: number
port
: number
6
(property) Config.apiKey: string
apiKey
: string
7
}
8
9
// Create a configuration object with sample values
10
const
const makeConfig: (name: string) => Config
makeConfig
= (
(parameter) name: string
name
: string):
interface Config
Config
=> ({
11
(property) Config.host: string
host
: `${
(parameter) name: string
name
}.example.com`,
12
(property) Config.port: number
port
: 8080,
13
(property) Config.apiKey: string
apiKey
: "12345-abcde"
14
})
15
16
// Simulate retrieving configuration from a remote node
17
const
const remoteConfig: (name: string) => Effect.Effect<Config, Error>
remoteConfig
= (
(parameter) name: string
name
: string):
import Effect
Effect
.
interface Effect<out A, out E = never, out R = never> namespace Effect

The `Effect` interface defines a value that lazily describes a workflow or job. The workflow requires some context `R`, and may fail with an error of type `E`, or succeed with a value of type `A`. `Effect` values model resourceful interaction with the outside world, including synchronous, asynchronous, concurrent, and parallel interaction. They use a fiber-based concurrency model, with built-in support for scheduling, fine-grained interruption, structured concurrency, and high scalability. To run an `Effect` value, you need a `Runtime`, which is a type that is capable of executing `Effect` values.

Effect
<
interface Config
Config
,
interface Error
Error
> =>
18
import Effect
Effect
.
const gen: <YieldWrap<Effect.Effect<never, Error, never>> | YieldWrap<Effect.Effect<void, never, never>>, Config>(f: (resume: Effect.Adapter) => Generator<...>) => Effect.Effect<...> (+1 overload)
gen
(function* () {
19
// Simulate node3 being the only one with available config
20
if (
(parameter) name: string
name
=== "node3") {
21
yield*
import Console
Console
.
const log: (...args: ReadonlyArray<any>) => Effect.Effect<void>
log
(`Config for ${
(parameter) name: "node3"
name
} found`)
22
return
const makeConfig: (name: string) => Config
makeConfig
(
(parameter) name: "node3"
name
)
23
} else {
24
yield*
import Console
Console
.
const log: (...args: ReadonlyArray<any>) => Effect.Effect<void>
log
(`Unavailable config for ${
(parameter) name: string
name
}`)
25
return yield*
import Effect
Effect
.
const fail: <Error>(error: Error) => Effect.Effect<never, Error, never>
fail
(new
var Error: ErrorConstructor new (message?: string) => Error
Error
(`Config not found for ${
(parameter) name: string
name
}`))
26
}
27
})
28
29
// Define the master configuration and potential fallback nodes
30
const
const masterConfig: Effect.Effect<Config, Error, never>
masterConfig
=
const remoteConfig: (name: string) => Effect.Effect<Config, Error>
remoteConfig
("master")
31
const
const nodeConfigs: Effect.Effect<Config, Error, never>[]
nodeConfigs
= ["node1", "node2", "node3", "node4"].
(method) Array<string>.map<Effect.Effect<Config, Error, never>>(callbackfn: (value: string, index: number, array: string[]) => Effect.Effect<Config, Error, never>, thisArg?: any): Effect.Effect<...>[]

Calls a defined callback function on each element of an array, and returns an array that contains the results.

map
(
const remoteConfig: (name: string) => Effect.Effect<Config, Error>
remoteConfig
)
32
33
// Attempt to find a working configuration,
34
// starting with the master and then falling back to other nodes
35
const
const config: Effect.Effect<Config, Error, never>
config
=
import Effect
Effect
.
const firstSuccessOf: <Effect.Effect<Config, Error, never>>(effects: Iterable<Effect.Effect<Config, Error, never>>) => Effect.Effect<Config, Error, never>

This function takes an iterable of `Effect` values and returns a new `Effect` value that represents the first `Effect` value in the iterable that succeeds. If all of the `Effect` values in the iterable fail, then the resulting `Effect` value will fail as well. This function is sequential, meaning that the `Effect` values in the iterable will be executed in sequence, and the first one that succeeds will determine the outcome of the resulting `Effect` value.

firstSuccessOf
([
const masterConfig: Effect.Effect<Config, Error, never>
masterConfig
, ...
const nodeConfigs: Effect.Effect<Config, Error, never>[]
nodeConfigs
])
36
37
// Run the effect to retrieve the configuration
38
const
const result: Config
result
=
import Effect
Effect
.
const runSync: <Config, Error>(effect: Effect.Effect<Config, Error, never>) => Config
runSync
(
const config: Effect.Effect<Config, Error, never>
config
)
39
40
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) globalThis.Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const result: Config
result
)
41
/*
42
Output:
43
Unavailable config for master
44
Unavailable config for node1
45
Unavailable config for node2
46
Config for node3 found
47
{ host: 'node3.example.com', port: 8080, apiKey: '12345-abcde' }
48
*/