npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cocreate/server-container

v1.5.0

Published

Hardened V8 isolated execution engine for CoCreate Server. Executes multi-tenant dynamic scripts inside sandboxed worker threads with untamperable host-side bandwidth metering and unified container interfaces.

Readme

CoCreate Server Container

An isolated V8 execution engine designed to execute dynamic multi-tenant scripts within hardened sandboxes. Featuring untamperable host-side metering, single-object container.send(data) messaging, and deterministic resource boundaries, this module allows CoCreate applications to run custom user code safely without risking host server stability or cross-tenant data leaks.


Documentation

For full API references, security isolation specifications, execution hooks, and examples, visit the CoCreate Server Container documentation:

https://cocreatejs.com/docs/server-container


Table of Contents


Hardened Two-Layer Execution Engine

Running untrusted, tenant-written code on a shared server presents significant risks, from event loop starvation and memory exhaustion to global scope tampering. @cocreate/server-container solves this by strictly separating host control logic from tenant script execution into two distinct architectural layers.

┌────────────────────────────────────────────────────────────────────────────┐
│ LAYER 1: HOST APPLICATION BRIDGE (Main Node.js Server Process)             │
│                                                                            │
│ • Manages worker thread lifecycles & resource boundaries                   │
│ • Calculates untamperable usage metrics on the host thread                 │
│ • Intercepts & routes database / system RPC calls (RPC_SEND)               │
│ • Enforces hard memory ceilings & execution timeout timers                 │
└─────────────────────────────────────┬──────────────────────────────────────┘
                                      │
                     In-Memory IPC Bridge (parentPort)
                                      │
┌─────────────────────────────────────▼──────────────────────────────────────┐
│ LAYER 2: ISOLATED EXECUTION ENGINE (V8 Worker Thread Sandbox)              │
│                                                                            │
│ • Pure V8 execution thread evaluated directly from memory                  │
│ • Exposes frozen, immutable global container namespace                     │
│ • Encapsulates messaging bridges inside private closure scope              │
│ • Overrides globalThis.fetch for network bandwidth metering                │
└────────────────────────────────────────────────────────────────────────────┘

Private IIFE Encapsulation

All host communication primitives (parentPort), active request maps, and event listeners are encapsulated inside a private closure before user code is evaluated. Tenant scripts executed via AsyncFunction("data", script) have no access to the outer module scope, preventing interception or tampering with IPC bridges.


Why CoCreate Server Container?

Traditional containerization solutions such as Docker or full virtual machines introduce significant cold-start latency and memory overhead, making them impractical for lightweight, high-frequency tenant scripts.

Conversely, executing user code directly inside the primary Node.js process exposes global variables, unrestricted process.env access, and the possibility of blocking the host event loop.

@cocreate/server-container bridges this gap using lightweight V8 worker thread isolates.

Features

  • Sub-10ms Cold Starts: Isolates are instantiated directly from in-memory source without disk access.
  • Hard Memory Limits: Configurable V8 heap limits prevent runaway scripts from impacting the host.
  • Execution Timeouts: Host-managed timers terminate stalled or infinite-loop executions automatically.
  • Single Object API: Every operation follows the CoCreate standard of accepting a single data object.

Unified Immutable Runtime Interface

Scripts communicate with the host exclusively through a locked-down, read-only container interface.

The global namespace is created using Object.defineProperty() with writable: false and configurable: false, then frozen using Object.freeze().

Available Interface

container.send(data);      // Execute RPC requests
container.on(event, fn);   // Listen for host events

Executing a Script

const { organization_id, filter } = data;

const result = await container.send({
	method: "object.read",
	array: "products",
	object: {
		category: filter
	},
	organization_id
});

return {
	status: "success",
	count: result.object.length
};

Untamperable Bandwidth Metering

Execution billing is calculated entirely by the host process, ensuring tenant code cannot manipulate usage accounting.

Billable usage combines:

  • Base isolate allocation cost
  • Input payload size
  • Output payload size
  • External network traffic performed through fetch

Billable Usage Formula

[ B_{total}=B_{base}+\frac{D_{input}+D_{output}+D_{fetch}}{1024\times1024} ]

Where:

  • Base allocation: 2 MB
  • Input: serialized request size
  • Output: serialized response size
  • Fetch: downloaded network payloads

Every execution automatically records an immutable usage entry in the container ledger.


Host RPC Delegation & Child Isolate Spawning

Since V8 worker isolates cannot directly create nested isolates, sub-container execution is delegated back to the host.

const result = await container.send({
	method: "container.send",
	script: "return data.a + data.b;",
	data: {
		a: 15,
		b: 25
	},
	organization_id: data.organization_id
});

The host validates the tenant context, creates a sibling isolate, executes the request, and returns the result to the parent container.


Configuration

Initialize the container engine during server startup.

import serverContainer from "@cocreate/server-container";

serverContainer.init(server);

const response = await serverContainer.send({
	script: `
		const orders = await container.send({
			method: "object.read",
			array: "orders"
		});

		return {
			total: orders.length
		};
	`,
	organization_id: "org_654321",
	memoryLimitMB: 128,
	timeoutMs: 5000
});

console.log(response.result);
console.log(response.usage);

Installation

NPM

npm install @cocreate/server-container

Yarn

yarn add @cocreate/server-container

Announcements

Release notes, security improvements, execution engine enhancements, and performance optimizations are available on GitHub:

  • https://github.com/CoCreate-app/CoCreate-server-container/releases

Roadmap

Upcoming capabilities include:

  • V8 Heap Snapshot Warm-Up: Faster startup using precompiled heap snapshots.
  • WebAssembly (Wasm) Isolation: Secure execution of WebAssembly modules within isolated runtimes.
  • Shared Runtime Pools: Reusable worker pools to reduce initialization overhead.
  • Execution Profiling: Built-in CPU, memory, and execution statistics for sandbox workloads.

How to Contribute

We welcome pull requests for performance improvements, security enhancements, documentation, and new adapters.

Please review the contribution guide before submitting changes:

  • https://github.com/CoCreate-app/CoCreate-server-container/blob/master/CONTRIBUTING.md

To report bugs or request new features, please use GitHub Issues:

  • https://github.com/CoCreate-app/CoCreate-server-container/issues

About

@cocreate/server-container is designed, built, and maintained by the CoCreate Developer Experience Team.

[!NOTE] Questions about sandbox execution, runtime isolation, usage metering, or custom execution environments can be discussed on GitHub Discussions or in the CoCreate Discord community.

GitHub Discussions: https://github.com/CoCreate-app/CoCreate-server-container/discussions

@cocreate/server-container is open source and funded by CoCreate. CoCreate names and logos are trademarks of CoCreate, LLC.