CtrlK
BlogDocsLog inGet started
Tessl Logo

mcollina/nodejs-core

Debugs native module crashes, optimizes V8 performance, configures node-gyp builds, writes N-API/node-addon-api bindings, and diagnoses libuv event loop issues in Node.js. Use when working with C++ addons, native modules, binding.gyp, node-gyp errors, segfaults, memory leaks in native code, V8 optimization/deoptimization, libuv thread pool tuning, N-API or NAN bindings, build system failures, or any Node.js internals below the JavaScript layer.

99

Quality

99%

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

contributing.mdrules/

name:
contributing
description:
How to contribute to Node.js core, the process
metadata:
{"tags":"contributing, nodejs-core, pull-request, governance"}

Contributing to Node.js Core

This guide covers the process of contributing to the Node.js project, from finding issues to landing commits.

Getting Started

Setting Up the Development Environment

# Fork and clone
git clone https://github.com/YOUR_USERNAME/node.git
cd node

# Add upstream remote
git remote add upstream https://github.com/nodejs/node.git

# Build
./configure && make -j$(nproc)

# Verify
./node -v
make test

Understanding the Repository Structure

node/
├── src/                 # C++ source code
│   ├── node.cc          # Entry point
│   ├── node_*.cc        # Core modules (C++)
│   └── crypto/          # Crypto implementation
├── lib/                 # JavaScript source code
│   ├── internal/        # Internal modules
│   └── *.js             # Public API modules
├── deps/                # Dependencies
│   ├── v8/              # V8 engine
│   ├── uv/              # libuv
│   └── openssl/         # OpenSSL
├── test/                # Tests
│   ├── parallel/        # Parallel tests
│   ├── sequential/      # Sequential tests
│   └── fixtures/        # Test fixtures
├── doc/                 # Documentation
├── tools/               # Build tools
└── benchmark/           # Benchmarks

Finding Work

Good First Issues

# Browse issues labeled "good first issue"
# https://github.com/nodejs/node/labels/good%20first%20issue

# Or use GitHub CLI
gh issue list --label "good first issue" --repo nodejs/node

Issue Labels

LabelDescription
good first issueSuitable for newcomers
help wantedNeeds contributor help
confirmed-bugVerified bug
feature requestNew feature proposal
semver-majorBreaking change
semver-minorNew feature
semver-patchBug fix

Where to Contribute

  • Documentation: doc/ directory
  • Tests: test/ directory
  • JavaScript: lib/ directory
  • C++: src/ directory
  • Build: configure, Makefile, GYP files

Making Changes

Creating a Branch

# Update main
git checkout main
git pull upstream main

# Create feature branch
git checkout -b fix-issue-12345

Commit Message Format

subsystem: short description

Longer explanation of the change if needed.
Can span multiple paragraphs.

Fixes: https://github.com/nodejs/node/issues/12345
Refs: https://github.com/nodejs/node/pull/12344

Examples:

# Bug fix
fs: fix race condition in readdir

# New feature
stream: add toArray method

# Test
test: add missing coverage for http

# Documentation
doc: clarify buffer.slice behavior

# Build
build: fix gyp warnings on Windows

Code Style

# Run linters
make lint
make lint-cpp
make lint-js
make lint-md

# Auto-fix some issues
make lint-js-fix

Writing Tests

// test/parallel/test-fs-read.js
'use strict';
const common = require('../common');
const assert = require('assert');
const fs = require('fs');

// Test description
{
  const expected = 'test content';
  const file = common.tmpDir + '/test-file.txt';

  fs.writeFileSync(file, expected);

  fs.readFile(file, 'utf8', common.mustCall((err, data) => {
    assert.ifError(err);
    assert.strictEqual(data, expected);
  }));
}

// Use common.mustCall() to ensure callbacks are called
// Use common.mustNotCall() to ensure callbacks are not called
// Use assert.throws() for expected errors

Running Tests

# Run all tests
make test

# Run specific test
./node test/parallel/test-fs-read.js

# Run tests matching pattern
python tools/test.py parallel/test-fs-*

# Run with specific options
./node --test-isolation=none test/parallel/test-fs-read.js

# Run benchmarks
node benchmark/fs/readfile.js

Pull Request Process

Creating a PR

# Push to your fork
git push origin fix-issue-12345

# Create PR via GitHub CLI
gh pr create \
  --title "fs: fix race condition in readdir" \
  --body "Fixes #12345

This PR addresses the race condition in fs.readdir() by...

**Test plan:**
- Added test in test/parallel/test-fs-readdir-race.js
- Ran existing fs tests
"

PR Requirements

  1. Tests: Must include tests for changes
  2. Documentation: Update docs for new features
  3. Commits: Clean, atomic commits with proper format
  4. CI: All CI checks must pass
  5. Review: At least one collaborator approval

CI Checks

PRs run through extensive CI:

├── lint (code style)
├── test-linux (Ubuntu)
├── test-macos
├── test-windows
├── test-asan (Address Sanitizer)
├── test-valgrind
└── coverage

Addressing Review Feedback

# Make changes based on review
git add .
git commit -m "address review feedback"
git push origin fix-issue-12345

# Squash if needed
git rebase -i HEAD~3
git push --force origin fix-issue-12345

Landing Process

For Collaborators

# Fetch PR
git fetch upstream pull/12345/head:pr-12345
git checkout pr-12345

# Review changes
git log upstream/main..HEAD
git diff upstream/main

# Land (after approval)
git checkout main
git pull upstream main
git merge --squash pr-12345

# Add metadata
git commit --amend
# Add: PR-URL: https://github.com/nodejs/node/pull/12345
# Add: Reviewed-By: Name <email>

# Push
git push upstream main

Commit Metadata

subsystem: description

Detailed explanation of the change.

PR-URL: https://github.com/nodejs/node/pull/12345
Fixes: https://github.com/nodejs/node/issues/12344
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>

Governance

Working Groups

  • TSC (Technical Steering Committee): Technical direction
  • Collaborators: Commit access, can merge PRs
  • Contributors: Anyone who contributes

Becoming a Collaborator

  1. Make quality contributions over time
  2. Be nominated by existing collaborator
  3. Pass consensus-based vote

Decision Making

1. Consensus seeking
2. If no consensus, TSC vote
3. Lazy consensus for routine changes
4. Explicit approval for breaking changes

C++ Contribution Guidelines

Style Guide

// Use 2-space indentation
// Use snake_case for variables and functions
// Use PascalCase for classes
// Use SCREAMING_CASE for macros

class MyClass : public BaseClass {
 public:  // 1 space before public/private
  void DoSomething();

 private:
  int my_variable_;  // Trailing underscore for members
};

// Wrap at 80 characters
// Use nullptr, not NULL
// Prefer std::unique_ptr over raw pointers

Error Handling

// Use Maybe<T> for operations that can fail
v8::MaybeLocal<v8::Value> result = SomeOperation();
if (result.IsEmpty()) {
  // Handle error
  return;
}
v8::Local<v8::Value> value = result.ToLocalChecked();

// Use CHECK macros for invariants
CHECK_NOT_NULL(env);
CHECK_EQ(status, 0);
CHECK_GE(length, 0);

JavaScript Contribution Guidelines

Style

'use strict';  // Always include

// Use const/let, never var
const x = 1;
let y = 2;

// Use arrow functions for callbacks
array.map((item) => item.value);

// Destructuring
const { a, b } = obj;

// Template literals
const message = `Value is ${value}`;

// Use primordials for built-ins in internal code
const {
  ArrayPrototypeMap,
  ObjectDefineProperty,
} = primordials;

Internal Modules

// lib/internal/my_module.js
'use strict';

const {
  ArrayIsArray,
} = primordials;

// Internal binding
const { myBinding } = internalBinding('my_binding');

// Validators
const {
  validateString,
  validateNumber,
} = require('internal/validators');

function myFunction(arg) {
  validateString(arg, 'arg');
  // Implementation
}

module.exports = {
  myFunction,
};

Backporting

Cherry-picking to Release Lines

# Checkout release branch
git checkout v18.x

# Cherry-pick commit
git cherry-pick -x <commit-hash>

# Update commit message
git commit --amend
# Add: Backport-PR-URL: https://github.com/nodejs/node/pull/12346

When to Backport

  • Security fixes: Always
  • Bug fixes: If safe and requested
  • Features: Generally not (semver-minor)
  • Breaking changes: Never

Resources

rules

build-system.md

child-process-internals.md

commit-messages.md

contributing.md

crypto-internals.md

debugging-native.md

fs-internals.md

libuv-async-io.md

libuv-event-loop.md

libuv-thread-pool.md

memory-debugging.md

napi.md

native-memory.md

net-internals.md

node-addon-api.md

profiling-v8.md

streams-internals.md

v8-garbage-collection.md

v8-hidden-classes.md

v8-jit-compilation.md

worker-threads-internals.md

SKILL.md

tile.json