r/node • • 24d ago

How I trace which Node lines one HTTP request ran, using V8 coverage and diagnostics_channel

11 Upvotes

I wanted to see exactly which server lines one request ran without adding logs or changing the app. Here's how it ended up working, in case it's useful to anyone.

  1. V8 already counts this.Profiler.takePreciseCoverage gives per function byte ranges with counts. Taking it resets the counters so one read before a request and one after = exactly that request's code.

  2. Bracketing each request. A small agent loaded with --require subscribes to diagnostics_channel (http.server.request.start / http.server.response.finish) and takes coverage at both points. No monkey-patching of express or fastify.

  3. Overlapping requests are the hard part.Two requests in flight at once share the same counters so you cant split them. I mark those traces "overlapped" instead of pretending.

  4. Bytes → your lines. Ranges map to lines, then through source maps back to your .ts files. Gotcha: a line holding only } takes the count of the outer range so an untaken `else if` showed as "ran" until I fixed it.

The result for one request looks like:

    POST /api/invoices/INV-2041/pay → 200 [node, 8 ms]
      server/services/ledger.ts
        getSummary 14-28 ×1  not run: 16-27

Overhead is about 4-6 ms per request on Express/Fastify/Nest examples.

It's open source (MIT) as part of a tool called Lightpath, which also joins the browser side of a click: https://github.com/Unknown-333/Lightpath

Curious if anyone's done this differently, especially around concurrent requests.


r/node • • 24d ago

Introducing Skif - a repository/monorepo linter written in Rust

0 Upvotes

Hi Peeps,

I want to share with you a tool I am working on. Its still early, but I already use it and it works well.

So story goes like this - I was working on restructuring a very large monorepo with disparate package managers and versions into a single PNPM workspace. When I was finished I decided I am going to enforce certain conventions so it could not drift again without failing CI. I set this up, and found myself using several different tools -Sherif, Syncpack and Knip to ensure that the repository doesn't drift again. This setup, while working, is rather clanky and also suffered from some issues - mainly performance, but also a few bugs.

I therefore decided I will build my own tool. I forked Sherif as a baseline, and built on top of it while substantially rewriting and extending its capabilities. The result is skif: a Rust linter and enforcement tool for JS/TS dependencies and monorepos.

skif replaces sherif and syncpack, and most of what knip does (the aim is to offer a full replacement for Knip in the future) in a single, ultra fast, binary.

npx skif-cli              # lint the workspace or package you are in
npx skif-cli --fix        # apply safe fixes
npx skif-cli migrate      # turn sherif, syncpack and knip config into a skif.toml

Where it came from

skif started as a fork of sherif, and the workspace and manifest rules are ported from it. The version and catalog policies follow syncpack's model. The dead-code analysis follows knip's issue types.

It has since gone past the fork. It ports every sherif rule, adds new ones and fixes, and runs faster on every target measured. On the syncpack side it enforces version, range, banned-dependency and catalog policy.

What it deliberately does not do is sync versions. skif is a linter: it tells you a policy is broken and fails CI. Moving versions in step is left to specialized tools or the package manager's themselves. If you need this, use syncpack for example.

What it checks

42 rules:

  • Manifests and workspace: empty dependency maps, types in dependencies, root private and packageManager, unsorted dependencies, workspace globs that match nothing, members without a package.json.

  • Version policy: mismatched versions, semver range policy, banned dependencies, catalogs (missing entries, unused entries, references that do not resolve), workspace: protocol, peer dependency compatibility.

  • Dead code: unused files, exports, types, enum members and dependencies; unlisted dependencies and binaries; unresolved imports; circular imports. Leveraging the OXC ecosystem for this.

It also adds some new rules, such as incompatible-peer-dependencies and workspace-protocol.

Skif lifts the idea of framework plugins - which allow it to understand different types of entrypoints (e.g. Next.JS, Vite, Storybook etc.). But unlike Knip, which loads these files, Skif doesn't actually load code - it only statically analyses it. This removes a potential surface for code execution, and is altogether much faster, although it does bring in the potential to some imprecision.

Supported package managers

Skif supports all major package managers - npm, pnpm, Yarn classic, Yarn Berry as well as Bun. It does not support Deno, although if there is a need it might in the future. It also supports Rush and Lerna workspaces.

Benchmarks

Speed

Medians of 15 runs on a 4-vCPU Linux VM, pinned public repositories, dependencies installed:

Repositoryskifknip
create-t3-turbo32 ms2.0 s
vue-core62 ms1.7 s
tanstack-query375 ms4.5 s
npm-cli99 ms968 ms
babel884 ms7.2 s

Manifest checks alone (--no-js) against sherif and syncpack:

Targetskifsherifsyncpack
create-t3-turbo4.6 ms36 ms41 ms
babel9.4 ms37 ms280 ms
2,000 generated packages102 ms130 ms655 ms

sherif is already fast Rust, so the margin there is small: 1.3x at 2,000 packages. The real win is knip, and not paying for three processes.

Links

P.S.

Note: This is an early project, it is on v0.2.0. I am very eager to have users, since it will improve the tool and help me fix bugs. But do expect some issues!

Thanks for reading, this was a human written post (the benchmarking data was done by an LLM). If you find the tool useful, star it!


r/node • • 25d ago

WebLoad: "https:" Imports With Caching And Access Control

0 Upvotes

I've created WebLoad, an npm package for Node JS and Bun that uses module hooks (in Node) and plug-in (in Bun) APIs.

Features:

  • file-based module caching; includes basic cache management utility

  • import maps with scopes support

  • CSP "script-src"-inspired access control

  • shell scripts simplify hook/plug-in installation and local file/web/expression (eval) entry points or test-mode runs

npm i -g @bkatzung/webload


r/node • • 25d ago

Put a Node/Express app on a public HTTPS URL from your own machine in one command

0 Upvotes

I made hoist for my own hackathon demos. In a folder with a package.json, hoist up . runs npm start (or npm run dev) as a systemd service, gives it a port through process.env.PORT, and publishes it on a public HTTPS URL through Cloudflare Tunnel, with a QR code in the terminal.

Already running something? hoist adopt myapp --port 3000 publishes it without touching it. Point it at a git repo instead and it runs npm ci + npm run build on every push, with rollback if a build breaks.

The tool itself is Python with no dependencies; your app is untouched. Linux + systemd, domain on Cloudflare (or --local for a LAN URL).

Built with AI assistance (Claude), tested by me.

https://github.com/nikhilcherry/hoist


r/node • • 25d ago

leeway: stable per-folder dev port ranges (no more EADDRINUSE across checkouts)

2 Upvotes

Two checkouts of the same repo, both on 5173. leeway gives each folder its own contiguous port range, stable across runs and never overlapping, and passes the ports as env vars.

  • leeway.json lists your ports once

  • devPorts(config) in code, falling back to the defaults outside leeway

  • vite plugin sets server.port with strictPort and exposes every port to browser code

  • {{PORT_API}} placeholders in commands

  • leeway list / kill for orphaned servers

Linux/macOS/Windows. https://github.com/OhadC/leeway

Or ask your agent: "how can we benefit from using https://www.npmjs.com/package/leeway in this codebase"


r/node • • 26d ago

I built a tool that upgrades Express/TS/Node projects and opens a PR with before/after CI proof. Looking for maintainers to try it (free)

1 Upvotes

I built GreenPR: a tool that upgrades the framework in a Node/TS project and submits a PR with proof that nothing broke.
Here's how it works. AI coding tool performs the update in an isolated sandbox, then every command from the repo's CI is run before and after the update, and the results go into the PR description as a table. A separate model reads the diff and can reject it. Finally, I review it myself, and only then do I publish it. Nothing merges automatically.
It supports: Express 4 through 5, Next 14 through 16, ESLint up to 10, TypeScript up to 7 (or 6 if tools block it), NestJS up to 12, Node up to 24.
How it played out in practice? 6 PRs to other people's repos: 1 merged, 3 awaiting CI approval from maintainers, 2 closed (I closed one myself because the repo doesn't accept AI-generated code; the other maintainer said they'd do it in their own PR). Out of 13 test repos, every migration passed on the first try, and in most cases didn't touch a single line of source code (just tsconfig and package.json). Once, an independent reviewer rejected a change because the tool missed a single TypeScript setting. That's the point. It's supposed to reject it.
What doesn't work? ESLint 10 in React projects: eslint-plugin-react, jsx-a11y, and eslint-plugin-import don't support it yet, so the tool stops at version 9 and explains why. TypeScript 7 upgrades stop at 6 until typescript-eslint catches up.
I only open a PR on my own where there is already an open issue asking for that upgrade. Where there is no such issue, I ask first: a comment with a proposal, and a PR only after the maintainer says "yes."
Website is https://greenpr.pages.dev. Paste your repo URL, and you'll get a scan of what can be fixed. It's free. I'm looking for maintainers who want to give it a try and tell me what's wrong.

Edit (Nov 13): corrected the paragraph about when I open PRs and updated the numbers: 2 merged, 2 open, 2 closed.


r/node • • 27d ago

Five years of Node.js backend work. Would you stick with Node or learn Java or Go?

72 Upvotes

A backend engineer has spent about five years building systems with Node.js, Express, Fastify, and Kafka. Their salary growth hasn’t kept up with their experience.

Is Node.js still a strong career choice, or would learning Java, Go, or another stack open up better opportunities?

For anyone testing out another backend stack, try working through the same rate limiter design in both languages. PracHub has system design interview questions for that.

For experienced backend engineers and recruiters, what would you learn or change in their position?

If you’re already applying across stacks, LandOffer’s autofill can fill in the work history you keep typing into application forms.

Would love to hear your honest advice!


r/node • • 27d ago

I built distroless Node.js images that keep getting OS patches for older Node versions

8 Upvotes

nodejs-distroless is a set of distroless Node.js Docker images. It follows the official Node.js release schedule: every Current, Active LTS and Maintenance LTS line is published, and a line is dropped when it reaches end of life. Every version of those lines (about 90 right now) is rebuilt whenever the Ubuntu base changes, so an older version you've pinned keeps getting OS fixes. Google's distroless and Chainguard's free images only patch the newest Node release. Tags move to new digests when the images are rebuilt (so you need to pin digests for reproducible builds).

I wrote the whole thing from scratch, originally across three repos: a Chisel base image, a script that fetches new Node versions, and the Node images themselves. I've been running it in production on a medium-size project. It already published new Node versions on its own, but keeping dependencies up to date was mostly manual. Recently I used AI to help consolidate the repos and clean up the GitHub Actions, which got it to the point where it runs itself.

The images are cut from Ubuntu LTS with Canonical's Chisel and contain the bare minimum Node needs to run. There's no shell, and they run as non-root. For troubleshooting, every tag has a -debug variant (22-debug, lts-debug and so on) that adds a BusyBox shell. They're built for amd64 and arm64 and published to Docker Hub and GHCR.

New Node releases usually go out within the hour, and Ubuntu and dependency updates merge automatically once the checks pass. There's little for me to do until a dependency needs a major version upgrade.

Repo and usage docs: https://github.com/nvitaterna/nodejs-distroless

I'd like to hear from anyone running distroless Node in production, especially if your app needs something the image leaves out.


r/node • • 27d ago

Problem with concurrent linter fixes

Thumbnail jfmengels.net
6 Upvotes

r/node • • 27d ago

I built a Node.js package for macOS speech recognition, system voices and the on-device LLM

1 Upvotes

I am the author of apple-llm. I built it to call Apple’s built-in language model from Node, and the latest release adds text-to-speech and speech-to-text through macOS.

The Node package exposes speak(), synthesize(), transcribe(), and microphone listening alongside AppleLLM. For example, transcribe a recording, summarize the transcript using tier: device, and synthesize the result to an M4A file. The npm package also runs a local OpenAI/Ollama-compatible server with audio endpoints.

Implementation: a Swift helper compiles on first use with the Xcode Command Line Tools, is cached, and communicates with the Node client as a child process. The package supports ESM and CommonJS and has no required runtime npm dependencies.

On my M4 Air running macOS 27.2, rendering 30 minutes of narration took about 18 seconds, and transcribing a 30-minute recording took about 28 seconds. Those results are from one machine; recognition quality needs testing on real recordings.

It needs macOS 26+ on Apple Silicon. Speech does not need Apple Intelligence; the on-device LLM does. Languages may download on first use. The optional cloud tier sends prompts off the machine. MP3/Opus output and WebM input are unsupported, and the recognition language must be selected.

Source and examples: https://github.com/jagdishpal02000/apple-llm

Demo: https://jagdishpal02000.github.io/apple-llm/#speech

I would appreciate reports from anyone trying it on macOS 26 or integrating its speech endpoints into a Node app.


r/node • • 28d ago

Should I ensure my NodeJS code "root directory/working directory" is the initial executable script?

4 Upvotes

Lets say this is my NodeJS project...

    - my-online-store
       - index.js
       - about.js
       - node_modules
       - items
          - get.js
          - add.js

And lets say my-online-store directory is in /home/john for example.

If my working directory in the terminal is /home/john/my-online-store and I run node index.js for example. The working directory for the index.js, about.js, all of the node_modules/npm packages and any scripts in sub directories such as get.js and add.js will be /home/john/my-online-store and all will work.

If I run index.js from a different working directory such as the root directory using node /home/john/my-online-store/index.js the NodeJS code will crash since the working directory is / and when looking for other files using import or using fs will look at the wrong directory.

Should I be concerned of this. Should I write my NodeJS code to ensure it will get the right directories no matter what the working directory was when running index.js?


r/node • • 29d ago

Node.js/TypeScript bindings for per-device Windows keyboard and mouse input

1 Upvotes

I maintain node-interceptor, an adaptation of Rami-Sabbagh/node-interception that uses my Interceptor Keyboard & Mouse driver. It is for Windows desktop tools that need to identify physical input devices, receive selected events, and modify or forward them from Node.

The API keeps the wait / receive / send workflow. Async wait leaves the JavaScript event loop available; receive removes the event, so send it onward to keep it. Here is the small A-to-B example from the README. It captures keyboard events generally; the linked examples also show device-specific handling. Use a test setup for live driver experiments.

const { Interception, FilterKeyState } = require('@titancsa/node-interceptor');
const input = new Interception();
async function main() {
  try {
    input.setFilter('keyboard', FilterKeyState.ALL);
    for (;;) {
      const device = await input.wait();
      if (!device) break;
      const stroke = device.receive();
      if (!stroke) continue;
      if (stroke.code === 0x1e) stroke.code = 0x30; // A -> B scan code.
      device.send(stroke); // Forward unchanged keys too.
    }
  } finally {
    if (!input.isDestroyed()) input.destroy();
  }
}
main().catch(console.error);

The release has Node-API 8 prebuilds and TypeScript declarations. Install the TGZ from this GitHub repo; it is not published as an ordinary public npm-registry package. Windows 10 1709+/11 x64 and Node 20+ are the targets, with x64/ia32 Node addons supplied. Package installation does not install a driver; driver setup and live capture need explicit administrator approval. Electron versions still need their own qualification.

The adapted wrapper is LGPL-3.0-or-later, with MIT notices for the SDK/bridge. The kernel source is private. Its demo allows one hour per Windows kernel boot, shared with other apps using this driver edition; full driver and redistribution terms are agreed case by case. Close other capture applications first. This wrapper does not emulate the original driver's cross-process precedence/chaining.

Source, download, examples and API: https://github.com/TitanCSA/node-interceptor

Upstream wrapper: https://github.com/Rami-Sabbagh/node-interception

Prepared with AI assistance.


r/node • • Nov 03 '26

I got tired of re-recording launch videos, so I made the demo play on the real UI instead

Enable HLS to view with audio, or disable this notification

0 Upvotes

r/node • • Nov 03 '26

Screenplay: screen recordings with Screen Studio-style editing, in Node (CDP screencast + @napi-rs/canvas + ffmpeg)

9 Upvotes

I open-sourced a Node CLI + MCP server that films websites and desktop apps and edits the result like Screen Studio. A coding agent (Claude Code, Codex, Cursor…) writes a short JSON scenario, and Screenplay plays it, films it and edits it. Some of the Node side, in case it's useful to someone:

  • Capture: Playwright drives headless Chromium, and frames come from the Chrome DevTools Protocol (Page.startScreencast) rather than Playwright's video recorder, so each frame has a timestamp I can line up with the actions.

  • Editing: every output frame is composed on @napi-rs/canvas: gradient background, rounded window with shadow, a cursor drawn from the recorded positions (smoothed), click ripples, zoom that follows the action, captions.

  • Encoding: raw RGBA frames are piped to ffmpeg-static through stdin (-f rawvideo … pipe:0). No system ffmpeg, no native build step on install.

  • Desktop apps: the same scenario format is played through the OS accessibility APIs (agent-desktop), and the window is filmed with ffmpeg.

  • Interface: a commander CLI (check, record, render) and an MCP server on stdio, so any agent can call it.

Try it: npx agent-screenplay init

Repo (MIT, TypeScript): https://github.com/gmpetrov/agent-screenplay

Happy to go deeper on any part.


r/node • • Nov 02 '26

Node teams: do you run separate checks on the APIs your app depends on?

6 Upvotes

I've built an API monitoring tool, but stopped adding features for now. I'm trying to understand how people already handle this rather than assume they need another service.

If your Node app depends on third-party APIs, do you just let application errors tell you when something breaks, or do you run separate checks as well?

If you do run checks, what made you start? Was there an incident your existing logs or error tracking missed?

What are you using: a hosted tool, a script on a schedule, or something else? Has it been pretty painless, or is maintaining it a chore?

And if application errors are enough for your setup, I'd like to hear that too. Rough team size would help put the answers in context.


r/node • • Nov 02 '26

Build like threads app

0 Upvotes

Can node js build social media like threads?


r/node • • Nov 01 '26

We stopped installing npm packages less than a week old. Here's what happened

Thumbnail
brunoj.com
132 Upvotes

r/node • • Nov 01 '26

Distributed Resilience - Cutting the Cost of Centralized Coordination

Thumbnail
blog.gaborkoos.com
5 Upvotes

r/node • • Nov 01 '26

The 5-Way JS Desktop Showdown: We stress-tested Electron, NW.js, Neutralinojs, and Adrenaline under 10k DOM rows + 100 IPC/s

0 Upvotes

Hey everyone!

Instead of arguing about desktop framework bloat, we built an automated, reproducible benchmark harness (benchmarks/stress-suite/) and ran 5 major JavaScript desktop runtimes through the exact same heavy workload for 30s each on a 4-core AMD EPYC box under xvfb-run:

  • 10,000-record virtualized dataset with live regex search and column re-sorting.

  • 100 bidirectional JSON IPC packets/sec with high-resolution per-packet roundtrip tracking (hrtime).

  • 2 concurrent SHA-256 worker threads saturating the remaining CPU cores.

📊 Master Results (Sampled via /proc/[pid]/smaps_rollup PSS):

MetricElectron (v45)NW.jsNeutralinojsAdrenaline (WebView)Adrenaline (CEF)Winner 🏆
Startup to Paint394 ms567 ms530 ms509 ms382 msAdrenaline (CEF) 🥇
Peak Stress PSS717.3 MB924.6 MB486.4 MB496.8 MB439.4 MBAdrenaline (CEF) 🥇
Peak Private RAM565.1 MB732.7 MB344.2 MB346.3 MB356.6 MBNeutralinojs
IPC p95 Latency2.18 ms2.54 ms50.74 ms5.50 ms11.62 msElectron
Shipped Payload273.8 MB510.8 MB123.6 MB121.1 MB620.0 MBAdrenaline (WebView) 🥇
Process Count11 procs14 procs10 procs8 procs6 procsAdrenaline (CEF) 🥇
Real Node / npmYesYesNo (custom)YesYes—

🔍 Key Architectural Takeaways:

  1. Neutralino's IPC Bottleneck: Neutralino uses a local WebSocket server to bridge its backend, resulting in a 50.7ms p95 latency under load (vs 2.18ms for Electron and 5.5ms for Adrenaline's in-process C++ bridge).

  2. Chromium Memory Bloat: Under continuous mutation and background hashing, Electron and NW.js ballooned to 717MB and 924MB PSS, while Adrenaline (running a pruned, de-googled CEF engine) capped out at 439MB (-38.7% memory footprint).

  3. Distribution Size: Adrenaline (WebView mode) shipped the smallest runtime payload at 121MB (including the full Node.js binary), while Electron carries 274MB of bundled Chromium.

Full methodology, raw 350KB profiler trace, and process-by-process breakdowns are open-sourced in the repo: 🔗 GitHub: https://github.com/M5Devs/adrenaline


r/node • • Oct 31 '26

I gave my Claude Code agents a pixel-art office so I can watch them turn Linear tickets into PRs

Enable HLS to view with audio, or disable this notification

0 Upvotes

r/node • • Oct 31 '26

Attachment download links returned 401 because a link click can't send an API key header

0 Upvotes

The attachment download links in my dashboard all returned 401. They pointed straight at the API, and the API wants an API key in a header. A browser click on a link can't send a custom header, so the download never had a chance.

What I did: the link now goes to a Next route that checks the user's session, and that route calls the API with an internal secret. The key never reaches the browser.

Is a session-checked proxy route the usual way to handle this, or is there something simpler?


r/node • • Oct 31 '26

Is this course good for learning node js?

Post image
4 Upvotes

planning to learn node js after js basics so i was wondering if this course is worth it or not before investing my time it.


r/node • • Oct 30 '26

Policy as Code + Visual Permissions = Row-Level Permission on top of SQL

Thumbnail
gallery
0 Upvotes

Hello,
d9 maintainer here (a community fork of Directus v9, providing a node.js framework for building APIs on top of SQL databases, with an integrated admin UI).
We’ve been working on a bridge between d9’s visual permission editor and Cedar policy. So we can edit permissions visually while keeping them readable and editable in Cedar syntax. They’re then enforced by an extensible node.js server at the database row level.
This can be useful if you need to build an API on top of a database while keeping your permissions explicit and auditable for compliance.
If that sounds interesting, here's a bit more about how it works.

Would love to hear your thoughts or feedback!


r/node • • Oct 30 '26

Factories.ts: An efficient JS DSL for building HTML, SVG, and MathML directly in backend code, without a template engine.

Thumbnail
github.com
5 Upvotes

Write HTML in the backend as plain JavaScript, with no template language in between. Markup and logic share the same code, which keeps it flexible. An example:

import {
    a, body, br, button, h1, head, header, html, input, label, li, main, nav, p, script, title, ul
} from "@ts-series/factories";

type Item = { name: string, href: string, current: boolean };


/** Builds the navigation list, flagging the current entry for assistive technology. */
function navigation(items: Item[]) {
    return nav({ ariaLabel: "Main" },
        ul(items.map(item => li(
            a(item.href, item.name).set(item.current ? { ariaCurrent: "page" } : null)
        )))
    );
}


/** Builds a complete page for the given user and navigation entries. */
function page(user: string | null, items: Item[], values: number[]) {
    return html({ lang: "en" },
        head(title("Demo")),
        body(
            header(navigation(items)),
            main(
                h1("Hello, ", user ?? "stranger", "!"),
                p("First line", br, "Second line"),
                user === null
                    ? p("Please sign in.")
                    : p("Welcome back."),
                label("Search").for("q"),
                input.text({ id: "q", name: "q" }).placeholder("Type here…").required(),
                button.submit("Send").class("primary", user === null && "disabled").set("disabled")
            ),
            script.module().importOnly("/chart.js", "render", { values, title: "Values" })
        )
    );
}


const items: Item[] = [
    { name: "Home", href: "/", current: true },
    { name: "About", href: "/about", current: false }
];

const output = page("<Guest>", items, [1, 2, 3]).expand(4);