@bun-native/runtime 0.34.0 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  Bun Native host process lifecycle and bridge runtime.
4
4
 
5
- Part of [Bun Native](https://github.com/AndrewM-F/bun-native), an experimental developer preview. Version 0.34.0 was built from [2796520d7849](https://github.com/AndrewM-F/bun-native/tree/2796520d7849194bc215b58a617be820e3bf4505) and published from GitHub Actions with npm provenance. Use the Bun revision pinned in that commit's toolchain.json. Start with the [getting-started guide](https://github.com/AndrewM-F/bun-native/blob/2796520d7849194bc215b58a617be820e3bf4505/docs/getting-started.md); `bun-native host install` fetches the matching release host. The license notice is in LICENSE.
5
+ Part of [Bun Native](https://github.com/AndrewM-F/bun-native), an experimental developer preview. Version 0.36.0 was built from [f2f30140e0ed](https://github.com/AndrewM-F/bun-native/tree/f2f30140e0ed6b7d029c4cadcffd0f1df8d74c04) and published from GitHub Actions with npm provenance. Use the Bun revision pinned in that commit's toolchain.json. Start with the [getting-started guide](https://github.com/AndrewM-F/bun-native/blob/f2f30140e0ed6b7d029c4cadcffd0f1df8d74c04/docs/getting-started.md); `bun-native host install` fetches the matching release host. The license notice is in LICENSE.
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "commit": "2796520d7849194bc215b58a617be820e3bf4505",
4
- "tree": "56d2f4303a50de6bb95ff296d1bb780a11f129a9",
3
+ "commit": "f2f30140e0ed6b7d029c4cadcffd0f1df8d74c04",
4
+ "tree": "b53bf37e9fa4db0b5a034469bc174ee92efd7421",
5
5
  "files": {
6
6
  "package.json": {
7
7
  "bytes": 2259,
8
- "sha256": "0713bd75afb84a486a0042aa34fa0dae28d70f4d742110465ae0e15dff0538df"
8
+ "sha256": "db2cf412e624700fb5c18f8a3923c67fa217d3db803a69daa06dac8f44d9ab9a"
9
9
  },
10
10
  "packages/runtime/package.json": {
11
11
  "bytes": 195,
@@ -24,8 +24,8 @@
24
24
  "sha256": "a89c677fad56ace6839bda86891fafa088f3a37e0248c313a72d7918a0538a10"
25
25
  },
26
26
  "packages/runtime/src/startup-trace.ts": {
27
- "bytes": 3345,
28
- "sha256": "19efe954374e1cd486277bc8df144d8dd711cffd12e2888d14021c871de840d6"
27
+ "bytes": 5241,
28
+ "sha256": "a89bd92e161a842ade9657813ea07c0c36f6369a7976cddb022f8a5bfdb4ba1b"
29
29
  },
30
30
  "LICENSE": {
31
31
  "bytes": 1075,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bun-native/runtime",
3
- "version": "0.34.0",
3
+ "version": "0.36.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -15,7 +15,7 @@
15
15
  "exports": "./src/index.ts",
16
16
  "description": "Bun Native host process lifecycle and bridge runtime.",
17
17
  "dependencies": {
18
- "@bun-native/protocol": "0.34.0"
18
+ "@bun-native/protocol": "0.36.0"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",
@@ -4,6 +4,23 @@ import { isAbsolute } from 'node:path'
4
4
  import { redactDiagnostic } from './exit-diagnostic.ts'
5
5
 
6
6
  const MAX_RECORDS = 256
7
+ /** Upper bound for an explicit diagnostic override; the default stays bounded. */
8
+ const MAX_RECORDS_LIMIT = 100_000
9
+
10
+ /**
11
+ * `BUN_NATIVE_STARTUP_TRACE_RECORDS` raises the record cap for a diagnostic run
12
+ * that needs more than the default window — attributing a stall that appears
13
+ * once per thousand updates, for example (#666). It stays bounded and only
14
+ * applies when tracing is already enabled.
15
+ */
16
+ function recordCap(): number {
17
+ const raw = process.env['BUN_NATIVE_STARTUP_TRACE_RECORDS']
18
+ if (raw === undefined) return MAX_RECORDS
19
+ const value = Number(raw)
20
+ if (!Number.isInteger(value) || value < MAX_RECORDS || value > MAX_RECORDS_LIMIT)
21
+ throw new Error(`BUN_NATIVE_STARTUP_TRACE_RECORDS must be ${MAX_RECORDS}..${MAX_RECORDS_LIMIT}`)
22
+ return value
23
+ }
7
24
 
8
25
  /** Explicit diagnostic mode only. This is not a request scheduler or transport proxy. */
9
26
  export class StartupTrace {
@@ -13,13 +30,30 @@ export class StartupTrace {
13
30
 
14
31
  private constructor(
15
32
  private readonly path: string,
16
- private readonly nonce: string
33
+ private readonly nonce: string,
34
+ private readonly maximum = MAX_RECORDS
17
35
  ) {}
18
36
 
19
37
  static fromEnvironment(): StartupTrace | undefined {
20
38
  if (process.env['BUN_NATIVE_STARTUP_TRACE'] !== '1') return
21
- const path = process.env['BUN_NATIVE_EVIDENCE_LOG']
22
- const nonce = process.env['BUN_NATIVE_EVIDENCE_NONCE']
39
+ // `BUN_NATIVE_STARTUP_TRACE_LOG` writes the transport trace on its own path.
40
+ // It exists so a timed workload can be traced without setting the host's
41
+ // `BUN_NATIVE_EVIDENCE_LOG`, which would add per-paint file I/O and perturb
42
+ // the measurement (#666). The evidence log remains the fallback.
43
+ const dedicated = process.env['BUN_NATIVE_STARTUP_TRACE_LOG']
44
+ // `{pid}` keeps one file per launching process. A comparison run starts a new
45
+ // app process per launch, and sharing one path merges their records, which is
46
+ // exactly what obscured the first attribution attempt (#666).
47
+ const path = (dedicated ?? process.env['BUN_NATIVE_EVIDENCE_LOG'])?.replaceAll(
48
+ '{pid}',
49
+ String(process.pid)
50
+ )
51
+ // A dedicated transport path needs no evidence nonce: a timed workload drops
52
+ // every `BUN_NATIVE_EVIDENCE_*` variable on purpose, and requiring one turned
53
+ // an opt-in diagnostic into a launch failure (#666). The evidence-log path
54
+ // keeps the strict binding because its records are qualification evidence.
55
+ const nonce =
56
+ process.env['BUN_NATIVE_EVIDENCE_NONCE'] ?? (dedicated ? 'transport-only' : undefined)
23
57
  if (
24
58
  !path ||
25
59
  !isAbsolute(path) ||
@@ -31,7 +65,7 @@ export class StartupTrace {
31
65
  })
32
66
  )
33
67
  throw new Error('Native startup tracing requires an absolute evidence path and valid nonce')
34
- return new StartupTrace(path, nonce)
68
+ return new StartupTrace(path, nonce, recordCap())
35
69
  }
36
70
 
37
71
  request(phase: string, command: Command, hostPid: number): void {
@@ -78,10 +112,10 @@ export class StartupTrace {
78
112
  }
79
113
 
80
114
  private write(phase: string, fields: Record<string, unknown>, terminal = false): void {
81
- if (this.unavailable || (!terminal && this.records >= MAX_RECORDS)) return
82
- if (!terminal && this.records === MAX_RECORDS - 1) {
115
+ if (this.unavailable || (!terminal && this.records >= this.maximum)) return
116
+ if (!terminal && this.records === this.maximum - 1) {
83
117
  phase = 'record_limit'
84
- fields = { host_pid: fields['host_pid'], maximum_records: MAX_RECORDS }
118
+ fields = { host_pid: fields['host_pid'], maximum_records: this.maximum }
85
119
  }
86
120
  const record = {
87
121
  nonce: this.nonce,