Skip to content

process metadata properties are writable unlike Node.js #34228

Open

Description

@liangmiQwQ

What version of Bun is running?

1.4.0-debug+be77b6528

Reproduced on the current main debug build and on Bun 1.3.14.

What platform is your computer?

Darwin 25.5.0 arm64

The affected properties are created by platform-independent process-object initialization code.

What steps can reproduce the bug?

Save this as repro.js:

"use strict";

function attributes(target, key) {
  const descriptor = Object.getOwnPropertyDescriptor(target, key);
  return {
    writable: descriptor.writable,
    enumerable: descriptor.enumerable,
    configurable: descriptor.configurable,
    getter: Boolean(descriptor.get),
    setter: Boolean(descriptor.set),
  };
}

const processProperties = [
  "version",
  "versions",
  "arch",
  "platform",
  "release",
  "pid",
  "argv0",
  "config",
  "features",
  "moduleLoadList",
  "_preload_modules",
  "stdin",
  "stdout",
  "stderr",
  "report",
];

for (const key of processProperties) {
  console.log(`process.${key}`, attributes(process, key));
}

console.log("process.versions.node", attributes(process.versions, "node"));
console.log("process.release.name", attributes(process.release, "name"));
console.log("process.config frozen", Object.isFrozen(process.config));
console.log("process.config.variables frozen", Object.isFrozen(process.config.variables));

const assignments = [
  ["process.version", () => {
    process.version = "overwritten";
  }],
  ["process.versions.node", () => {
    process.versions.node = "overwritten";
  }],
  ["process.release.name", () => {
    process.release.name = "overwritten";
  }],
  ["process.arch", () => {
    process.arch = "overwritten";
  }],
  ["process.pid", () => {
    process.pid = 1;
  }],
  ["process.config.variables", () => {
    process.config.variables.__repro = true;
  }],
];

for (const [name, assign] of assignments) {
  try {
    assign();
    console.log(`${name}: assignment succeeded`);
  } catch (error) {
    console.log(`${name}: ${error.name}`);
  }
}

Run it with both runtimes:

node repro.js
bun repro.js

What is the expected behavior?

Bun should match Node's property descriptors.

In Node.js v26.4.0:

  • process.version, versions, arch, platform, release, and pid are non-writable, enumerable, and configurable.
  • process.argv0 is non-writable and non-configurable.
  • process.config is non-writable and its complete object tree is recursively frozen.
  • process.features is non-writable and non-configurable.
  • Every existing entry of process.versions is non-writable.
  • The existing fields of process.release are non-writable.
  • process.moduleLoadList and process._preload_modules cannot be replaced, although their array contents remain mutable.
  • process.stdin, stdout, stderr, and report are getter-only properties.

Consequently, the assignments in the reproduction throw TypeError in strict mode.

Node's implementation uses READONLY_PROPERTY / READONLY_STRING_PROPERTY for the core metadata:

https://github.com/nodejs/node/blob/v26.4.0/src/node_process_object.cc

Node's upstream test also checks that every process.versions entry has writable === false:

https://github.com/nodejs/node/blob/v26.4.0/test/parallel/test-process-versions.js

What do you see instead?

On the current Bun debug build, all of the following become writable data properties after lazy initialization:

process.version
process.versions
process.arch
process.platform
process.release
process.pid
process.argv0
process.config
process.features
process.moduleLoadList
process._preload_modules
process.stdin
process.stdout
process.stderr
process.report

Their descriptors report writable: true, configurable: true.

All 25 existing process.versions.* fields and all existing process.release.* fields are also writable. The assignments in the reproduction succeed and change their values.

process.config itself is frozen, but the freeze is shallow:

Object.isFrozen(process.config); // true
Object.isFrozen(process.config.variables); // false

Node recursively freezes both.

Additional information

The likely common cause is the process lookup table in src/jsc/bindings/BunProcess.cpp: these lazy PropertyCallback entries do not use ReadOnly (and argv0 / features also need Node's exact non-configurable attributes).

The nested version and release fields are installed with default putDirect(..., 0) attributes. constructProcessConfigObject only calls config->freeze(vm) on the root object.

Bun already exposes Bun.version and Bun.revision with ReadOnly|DontDelete, so this appears specific to the process-object implementation. process.revision is also writable even though Bun.revision is read-only, but it has no direct Node counterpart and may be better handled as part of the same audit.

I searched existing issues and PRs for this descriptor mismatch and did not find a dedicated report or active fix. PR #31831 ports many process compatibility tests, but it does not change these descriptors and does not vendor Node's test-process-versions.js.

Activity

  1. robobun commented on Jul 15, 2026

    @robobun
    Collaborator

    Reproduced on the main debug build: every listed property was a writable data property and process.config was only shallowly frozen. A fix was ready in #34229 (descriptors match Node v26 for all 16 properties, read-only versions/release entries, deep-frozen config). The stale bot closed that PR after 90 days with no review objection. The branch still exists and a maintainer can reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions