Skip to content

runtime: createRequire rejects node:-prefixed builtins / missing diagnostics_channel — pi wall #3 (require('node:diagnostics_channel') via bundle shim) #6644

Description

@proggeramlug

Wall #3 of the pi coding-agent bring-up (tracker #6564; walls #1 #6593 and #2 #6604 fixed). With both fixes applied, the compiled pi binary gets through module init and dies at:

Error: Perry createRequire() currently supports built-in modules only; package/file require('node:diagnostics_channel') is not supported

Site: lru-cache's node build (pi bundle line ~5520) does require('node:diagnostics_channel') through the bundle's createRequire(import.meta.url) shim (the esbuild createRequire banner pattern — any ESM bundle of CJS deps produces this shape).

So perry's createRequire either (a) doesn't include diagnostics_channel in its builtin set, or (b) rejects the node:-prefixed form on this path while supporting the bare name. Both are worth fixing:

  • normalize node:-prefixed specifiers in createRequire before the builtin lookup (Node accepts both forms);
  • ensure diagnostics_channel is present as at least a functional stub (channel(), hasSubscribers, subscribe/unsubscribe, tracingChannel) — lru-cache only uses it for optional diagnostics, so a spec-shaped no-op channel suffices for this consumer, though a real implementation serves opentelemetry-adjacent code later.

Repro: HOME=$(mktemp -d) /Users/amlug/projects/perry/secret-tests/pi-target/dist/pi-native --help (binary built from the #6603+#6604 branches), or reduce to: an ESM file with const require = createRequire(import.meta.url); const dc = require('node:diagnostics_channel'); console.log(typeof dc.channel).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed defect or regressionparityCompatibility gap with Node.js, ECMAScript, or the supported ecosystem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions