Runtime

Blocking versus nonblocking I/O

A nonblocking interface lets the caller proceed while work is pending; await suspends the async continuation, not the entire process. Synchronous filesystem calls occupy the calling JavaScript thread until they return. The fixture shows control flow, not measured speed or thread-pool implementation. Tested on Node.js 22.16.0. Example output (one line per entry): ["scheduled", "ink"].

Formal Syntax & Structure

nodejs syntaxnodejs
Concept: initiate I/O → await result

Return Value

Concept

No formal return value; see the selected I/O API.

Working Example

Example Snippetnodejs
import { mkdtemp, writeFile, readFile, rm } from 'node:fs/promises';import { tmpdir } from 'node:os';import { join } from 'node:path';const dir = await mkdtemp(join(tmpdir(), 'bm-'));try {    const path = join(dir, 'a');    await writeFile(path, 'ink');    const pending = readFile(path, 'utf8');    console.log('scheduled');    console.log(await pending);}finally {    await rm(dir, { recursive: true, force: true });}
Node.js Reference