Skip to content

Commit 6d91948

Browse files
authored
docs: fill v2.7 coverage gaps across multiple pages (#3168)
1 parent 2fc3908 commit 6d91948

5 files changed

Lines changed: 291 additions & 0 deletions

File tree

runtime/fundamentals/cron.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,18 @@ of this runtime API: it discovers your [`Deno.cron()`](/api/deno/~/Deno.cron)
7272
definitions at deployment time, schedules and invokes them, handles retries, and
7373
surfaces runs in a dashboard — so you don't need to keep a long-running process
7474
up yourself.
75+
76+
## OpenTelemetry
77+
78+
When [OpenTelemetry](/runtime/fundamentals/open_telemetry/) is enabled
79+
(`OTEL_DENO=true`), each [`Deno.cron()`](/api/deno/~/Deno.cron) invocation
80+
automatically produces an OpenTelemetry span. This lets you trace cron execution
81+
alongside your other instrumented code:
82+
83+
```sh
84+
OTEL_DENO=true deno run --unstable-cron main.ts
85+
```
86+
87+
Each cron invocation creates a span named after the cron job. The span covers
88+
the duration of the handler function, and any spans created inside the handler
89+
are nested under it as children.

runtime/fundamentals/debugging.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,34 @@ step through your code.
3131
deno run --inspect your_script.ts
3232
```
3333

34+
You can optionally specify a host and port for the inspector server. Both the
35+
full address and a bare port number are accepted:
36+
37+
```sh
38+
# Default: listen on 127.0.0.1:9229
39+
deno run --inspect your_script.ts
40+
41+
# Custom port
42+
deno run --inspect=9230 your_script.ts
43+
44+
# Custom host and port
45+
deno run --inspect=0.0.0.0:9229 your_script.ts
46+
```
47+
48+
### --inspect-publish-uid
49+
50+
By default, Deno prints the inspector WebSocket URL to stderr when it starts
51+
listening. You can control this with `--inspect-publish-uid`:
52+
53+
- `stderr` (default) — prints the URL to stderr on startup
54+
- `http` — exposes the URL via the `/json/list` HTTP endpoint on the inspector
55+
port, instead of printing it; useful for programmatic tooling that polls for
56+
available targets
57+
58+
```sh
59+
deno run --inspect --inspect-publish-uid=http your_script.ts
60+
```
61+
3462
:::note
3563

3664
If you use the `--inspect` flag, the code will start executing immediately. If
@@ -512,6 +540,39 @@ For full details on Deno's OpenTelemetry integration, including custom metrics,
512540
traces, and configuration options, see the
513541
[OpenTelemetry documentation](/runtime/fundamentals/open_telemetry).
514542

543+
## Debugging Web Workers
544+
545+
Starting with Deno 2.7, Web Workers can be debugged through Chrome DevTools and
546+
VS Code. When you run your program with any `--inspect` flag, each spawned
547+
worker appears as a separate target in `chrome://inspect` alongside the main
548+
thread.
549+
550+
```ts title="main.ts"
551+
const worker = new Worker(import.meta.resolve("./worker.ts"), {
552+
type: "module",
553+
});
554+
worker.postMessage("start");
555+
```
556+
557+
```ts title="worker.ts"
558+
self.onmessage = (e) => {
559+
console.log("Worker received:", e.data);
560+
// Set breakpoints here in DevTools
561+
};
562+
```
563+
564+
```sh
565+
deno run --inspect-brk --allow-read main.ts
566+
```
567+
568+
Open `chrome://inspect`, and you will see both `main.ts` and `worker.ts` listed
569+
as separate inspectable targets. Click **Inspect** on the worker target to open
570+
a dedicated DevTools panel for that worker where you can set breakpoints, step
571+
through code, and inspect variables independently of the main thread.
572+
573+
In VS Code with the Deno extension, workers appear as separate threads in the
574+
**Call Stack** panel of the debugger.
575+
515576
## TLS session debugging
516577

517578
Set the `SSLKEYLOGFILE` environment variable to log TLS session keys to a file.

runtime/fundamentals/open_telemetry.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Deno automatically creates spans for various operations, such as:
107107

108108
- Incoming HTTP requests served with [`Deno.serve`](/api/deno/~/Deno.serve).
109109
- Outgoing HTTP requests made with [`fetch`](/api/web/~/fetch).
110+
- [`Deno.cron()`](/api/deno/~/Deno.cron) job invocations (added in Deno 2.7).
110111

111112
#### [`Deno.serve`](/api/deno/~/Deno.serve)
112113

runtime/reference/node_apis.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,77 @@ importing them from the relevant `node:` module.
9898
| [`WritableStreamDefaultController`](https://nodejs.org/api/globals.html#class-writablestreamdefaultcontroller) ||
9999
| [`WritableStreamDefaultWriter`](https://nodejs.org/api/globals.html#class-writablestreamdefaultwriter) ||
100100

101+
## Module notes
102+
103+
### node:worker_threads
104+
105+
Deno 2.7 significantly improved `node:worker_threads` compatibility:
106+
107+
- `stdout` and `stderr` streams are forwarded correctly from workers to the
108+
parent process.
109+
- `worker.terminate()` now resolves with the correct exit code.
110+
- `workerData`, `execArgv`, and `threadName` options are supported.
111+
- `worker.performance.eventLoopUtilization()` and `worker.cpuUsage()` are
112+
implemented.
113+
- `BroadcastChannel` from worker threads is properly ref'd/unref'd.
114+
115+
### node:child_process
116+
117+
Deno 2.7 improved `node:child_process` compatibility:
118+
119+
- `stdio` streams (`stdin`, `stdout`, `stderr`) are exposed as `Socket`
120+
instances, matching Node.js behavior.
121+
- Shell redirection (`>`, `<`, `>>`) works in `exec()` and `execSync()`.
122+
- `fork()` accepts a `URL` as the module path.
123+
- `timeout` and `killSignal` options are supported in `exec()` and `spawn()`.
124+
- `NODE_OPTIONS` environment variable is respected for `fork()`'d processes.
125+
126+
### node:zlib
127+
128+
Deno 2.7 added Zstd compression support to `node:zlib`:
129+
130+
```ts
131+
import zlib from "node:zlib";
132+
import { promisify } from "node:util";
133+
134+
const compress = promisify(zlib.zstdCompress);
135+
const decompress = promisify(zlib.zstdDecompress);
136+
137+
const compressed = await compress(Buffer.from("Hello, Deno!"));
138+
const result = await decompress(compressed);
139+
console.log(result.toString()); // "Hello, Deno!"
140+
```
141+
142+
The synchronous variants `zlib.zstdCompressSync()` and
143+
`zlib.zstdDecompressSync()` are also available.
144+
145+
### node:sqlite
146+
147+
Deno 2.7 added several new APIs to `node:sqlite`:
148+
149+
- `DatabaseSync.setAuthorizer(callback)` — registers a callback invoked for
150+
every SQL operation, enabling fine-grained access control over which tables
151+
and operations are permitted:
152+
153+
```ts
154+
import { constants, DatabaseSync } from "node:sqlite";
155+
156+
const db = new DatabaseSync(":memory:");
157+
db.exec("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)");
158+
159+
// Allow reads, deny everything else
160+
db.setAuthorizer((_action, _table) => {
161+
return constants.SQLITE_OK;
162+
});
163+
```
164+
165+
- `DatabaseSync.enableDefensive(enabled)` — enables or disables defensive mode,
166+
which prevents potentially dangerous database operations such as schema
167+
modifications at runtime.
168+
169+
- `DatabaseSync.createTagStore()` — creates a prepared-statement cache that maps
170+
SQL strings to compiled statements for efficient repeated execution.
171+
101172
## Node test results
102173

103174
If you're interested in a more detailed view of compatibility on a per-test-case

runtime/reference/web_platform_apis.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,149 @@ These types are useful for graphics work; applying transforms to canvas
615615
drawings, computing layout math, or porting browser code that depends on
616616
geometry types.
617617

618+
## navigator
619+
620+
Deno implements a subset of the
621+
[`navigator`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator)
622+
global. The following properties are available:
623+
624+
- `navigator.userAgent` — always `"Deno/<version>"`
625+
- `navigator.platform` — the underlying OS platform (e.g. `"Linux x86_64"`,
626+
`"MacIntel"`, `"Win32"`). Added in Deno 2.7.
627+
- `navigator.hardwareConcurrency` — number of logical CPU cores
628+
629+
```ts
630+
console.log(navigator.userAgent); // "Deno/2.7.0"
631+
console.log(navigator.platform); // e.g. "Linux x86_64", "MacIntel", "Win32"
632+
console.log(navigator.hardwareConcurrency); // e.g. 8
633+
```
634+
635+
## Temporal
636+
637+
The [Temporal API](https://tc39.es/proposal-temporal/docs/) is a modern
638+
date/time library that replaces `Date` for most use cases. It was stabilized in
639+
Deno 2.7 and is available as a global without any flags.
640+
641+
```ts
642+
// Current date/time in local timezone
643+
const now = Temporal.Now.plainDateTimeISO();
644+
console.log(now.toString()); // e.g. "2025-03-12T10:30:00"
645+
646+
// Parse a date
647+
const date = Temporal.PlainDate.from("2025-03-12");
648+
console.log(date.month); // 3
649+
650+
// Timezone-aware
651+
const zonedNow = Temporal.Now.zonedDateTimeISO("America/New_York");
652+
console.log(zonedNow.timeZoneId); // "America/New_York"
653+
```
654+
655+
Prior to Deno 2.7, Temporal required the `--unstable-temporal` flag.
656+
657+
## CompressionStream and DecompressionStream
658+
659+
Deno supports
660+
[`CompressionStream`](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream)
661+
and
662+
[`DecompressionStream`](https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream)
663+
for streaming compression and decompression.
664+
665+
### Supported formats
666+
667+
| Format | String | Notes |
668+
| ----------- | --------------- | ------------------ |
669+
| gzip | `"gzip"` | RFC 1952 |
670+
| deflate | `"deflate"` | zlib (RFC 1950) |
671+
| deflate-raw | `"deflate-raw"` | raw DEFLATE (1951) |
672+
| Brotli | `"brotli"` | Added in Deno 2.7 |
673+
674+
```ts
675+
// Compress with Brotli
676+
const input = new TextEncoder().encode("Hello, Deno!");
677+
const cs = new CompressionStream("brotli");
678+
const writer = cs.writable.getWriter();
679+
writer.write(input);
680+
writer.close();
681+
const compressed = await new Response(cs.readable).arrayBuffer();
682+
683+
// Decompress
684+
const ds = new DecompressionStream("brotli");
685+
const writer2 = ds.writable.getWriter();
686+
writer2.write(new Uint8Array(compressed));
687+
writer2.close();
688+
const result = await new Response(ds.readable).text();
689+
console.log(result); // "Hello, Deno!"
690+
```
691+
692+
## Web Crypto
693+
694+
Deno supports the
695+
[Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API)
696+
via `crypto.subtle`. Starting with Deno 2.7, SHA-3 hash algorithms are
697+
supported:
698+
699+
- `SHA3-256`
700+
- `SHA3-384`
701+
- `SHA3-512`
702+
703+
```ts
704+
const data = new TextEncoder().encode("Hello, Deno!");
705+
const hash = await crypto.subtle.digest("SHA3-256", data);
706+
console.log(new Uint8Array(hash));
707+
```
708+
709+
## createImageBitmap
710+
711+
Deno supports
712+
[`createImageBitmap()`](https://developer.mozilla.org/en-US/docs/Web/API/createImageBitmap)
713+
for decoding images into `ImageBitmap` objects that can be used with
714+
[`OffscreenCanvas`](#offscreencanvas).
715+
716+
### Supported input formats
717+
718+
| Format | Notes |
719+
| ------ | ----------------- |
720+
| PNG | |
721+
| JPEG | |
722+
| BMP | |
723+
| GIF | Added in Deno 2.7 |
724+
| WebP | Added in Deno 2.7 |
725+
726+
```ts
727+
const data = await Deno.readFile("./image.gif");
728+
const bitmap = await createImageBitmap(new Blob([data]));
729+
console.log(bitmap.width, bitmap.height);
730+
```
731+
732+
## File locking
733+
734+
[`Deno.FsFile`](/api/deno/~/Deno.FsFile) supports advisory file locking to
735+
coordinate access between processes:
736+
737+
- [`lock(exclusive?)`](/api/deno/~/Deno.FsFile.prototype.lock) — acquires a
738+
lock. Shared (read) by default; pass `true` for exclusive (write). Blocks if
739+
an incompatible lock is held.
740+
- [`lockSync(exclusive?)`](/api/deno/~/Deno.FsFile.prototype.lockSync) —
741+
synchronous variant of `lock()`.
742+
- [`tryLock(exclusive?)`](/api/deno/~/Deno.FsFile.prototype.tryLock) —
743+
non-blocking. Returns `true` if the lock was acquired, `false` otherwise.
744+
Added in Deno 2.7.
745+
- [`tryLockSync(exclusive?)`](/api/deno/~/Deno.FsFile.prototype.tryLockSync) —
746+
synchronous variant of `tryLock()`.
747+
748+
```ts
749+
const file = await Deno.open("./data.txt", { read: true, write: true });
750+
751+
const locked = await file.tryLock(true); // exclusive
752+
if (locked) {
753+
await file.write(new TextEncoder().encode("hello"));
754+
await file.unlock();
755+
} else {
756+
console.log("File is locked by another process, skipping.");
757+
}
758+
file.close();
759+
```
760+
618761
## Deviations of other APIs from spec
619762

620763
### Cache API

0 commit comments

Comments
 (0)