Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docker/build/darwin-arm64.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ RUN if [ "$BUILD_TARGET" = "engine" ] && [ "$BUILD_FRONTEND" = "true" ]; then \
export SKIP_WASM_BUILD=1 && \
pnpm install --ignore-scripts && \
VITE_APP_API_URL="${VITE_APP_API_URL}" VITE_FEATURE_FLAGS="${VITE_FEATURE_FLAGS}" npx turbo build:engine -F @rivetkit/engine-frontend; \
elif [ "$BUILD_TARGET" = "rivetkit-napi" ]; then \
export NODE_OPTIONS="--max-old-space-size=8192" && \
export SKIP_NAPI_BUILD=1 && \
export SKIP_WASM_BUILD=1 && \
pnpm install --ignore-scripts && \
npx turbo build:inspector-ui -F @rivetkit/engine-frontend; \
fi

RUN --mount=type=cache,id=cargo-registry-darwin-arm64,target=/usr/local/cargo/registry,sharing=locked \
Expand Down
6 changes: 6 additions & 0 deletions docker/build/darwin-x64.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ RUN if [ "$BUILD_TARGET" = "engine" ] && [ "$BUILD_FRONTEND" = "true" ]; then \
export SKIP_WASM_BUILD=1 && \
pnpm install --ignore-scripts && \
VITE_APP_API_URL="${VITE_APP_API_URL}" VITE_FEATURE_FLAGS="${VITE_FEATURE_FLAGS}" npx turbo build:engine -F @rivetkit/engine-frontend; \
elif [ "$BUILD_TARGET" = "rivetkit-napi" ]; then \
export NODE_OPTIONS="--max-old-space-size=8192" && \
export SKIP_NAPI_BUILD=1 && \
export SKIP_WASM_BUILD=1 && \
pnpm install --ignore-scripts && \
npx turbo build:inspector-ui -F @rivetkit/engine-frontend; \
fi

RUN --mount=type=cache,id=cargo-registry-darwin-x64,target=/usr/local/cargo/registry,sharing=locked \
Expand Down
6 changes: 6 additions & 0 deletions docker/build/linux-arm64-gnu.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ RUN if [ "$BUILD_TARGET" = "engine" ] && [ "$BUILD_FRONTEND" = "true" ]; then \
export SKIP_WASM_BUILD=1 && \
pnpm install --ignore-scripts && \
VITE_APP_API_URL="${VITE_APP_API_URL}" VITE_FEATURE_FLAGS="${VITE_FEATURE_FLAGS}" npx turbo build:engine -F @rivetkit/engine-frontend; \
elif [ "$BUILD_TARGET" = "rivetkit-napi" ]; then \
export NODE_OPTIONS="--max-old-space-size=8192" && \
export SKIP_NAPI_BUILD=1 && \
export SKIP_WASM_BUILD=1 && \
pnpm install --ignore-scripts && \
npx turbo build:inspector-ui -F @rivetkit/engine-frontend; \
fi

RUN --mount=type=cache,id=cargo-registry-linux-arm64-gnu,target=/usr/local/cargo/registry,sharing=locked \
Expand Down
6 changes: 6 additions & 0 deletions docker/build/linux-arm64-musl.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ RUN if [ "$BUILD_TARGET" = "engine" ] && [ "$BUILD_FRONTEND" = "true" ]; then \
export SKIP_WASM_BUILD=1 && \
pnpm install --ignore-scripts && \
VITE_APP_API_URL="${VITE_APP_API_URL}" VITE_FEATURE_FLAGS="${VITE_FEATURE_FLAGS}" npx turbo build:engine -F @rivetkit/engine-frontend; \
elif [ "$BUILD_TARGET" = "rivetkit-napi" ]; then \
export NODE_OPTIONS="--max-old-space-size=8192" && \
export SKIP_NAPI_BUILD=1 && \
export SKIP_WASM_BUILD=1 && \
pnpm install --ignore-scripts && \
npx turbo build:inspector-ui -F @rivetkit/engine-frontend; \
fi

RUN --mount=type=cache,id=cargo-registry-linux-arm64-musl,target=/usr/local/cargo/registry,sharing=locked \
Expand Down
6 changes: 6 additions & 0 deletions docker/build/linux-x64-gnu.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ RUN if [ "$BUILD_TARGET" = "engine" ] && [ "$BUILD_FRONTEND" = "true" ]; then \
export SKIP_WASM_BUILD=1 && \
pnpm install --ignore-scripts && \
VITE_APP_API_URL="${VITE_APP_API_URL}" VITE_FEATURE_FLAGS="${VITE_FEATURE_FLAGS}" npx turbo build:engine -F @rivetkit/engine-frontend; \
elif [ "$BUILD_TARGET" = "rivetkit-napi" ]; then \
export NODE_OPTIONS="--max-old-space-size=8192" && \
export SKIP_NAPI_BUILD=1 && \
export SKIP_WASM_BUILD=1 && \
pnpm install --ignore-scripts && \
npx turbo build:inspector-ui -F @rivetkit/engine-frontend; \
fi

# Build binary.
Expand Down
6 changes: 6 additions & 0 deletions docker/build/linux-x64-musl.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ RUN if [ "$BUILD_TARGET" = "engine" ] && [ "$BUILD_FRONTEND" = "true" ]; then \
export SKIP_WASM_BUILD=1 && \
pnpm install --ignore-scripts && \
VITE_APP_API_URL="${VITE_APP_API_URL}" VITE_FEATURE_FLAGS="${VITE_FEATURE_FLAGS}" npx turbo build:engine -F @rivetkit/engine-frontend; \
elif [ "$BUILD_TARGET" = "rivetkit-napi" ]; then \
export NODE_OPTIONS="--max-old-space-size=8192" && \
export SKIP_NAPI_BUILD=1 && \
export SKIP_WASM_BUILD=1 && \
pnpm install --ignore-scripts && \
npx turbo build:inspector-ui -F @rivetkit/engine-frontend; \
fi

RUN --mount=type=cache,id=cargo-registry-linux-x64-musl,target=/usr/local/cargo/registry,sharing=locked \
Expand Down
6 changes: 6 additions & 0 deletions docker/build/windows-x64.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ RUN if [ "$BUILD_TARGET" = "engine" ] && [ "$BUILD_FRONTEND" = "true" ]; then \
export SKIP_WASM_BUILD=1 && \
pnpm install --ignore-scripts && \
VITE_APP_API_URL="${VITE_APP_API_URL}" VITE_FEATURE_FLAGS="${VITE_FEATURE_FLAGS}" npx turbo build:engine -F @rivetkit/engine-frontend; \
elif [ "$BUILD_TARGET" = "rivetkit-napi" ]; then \
export NODE_OPTIONS="--max-old-space-size=8192" && \
export SKIP_NAPI_BUILD=1 && \
export SKIP_WASM_BUILD=1 && \
pnpm install --ignore-scripts && \
npx turbo build:inspector-ui -F @rivetkit/engine-frontend; \
fi

RUN --mount=type=cache,id=cargo-registry-windows-x64,target=/usr/local/cargo/registry,sharing=locked \
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/components/actors/actor-inspector-context.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions rivetkit-typescript/packages/rivetkit-napi/scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ if (process.env.SKIP_NAPI_BUILD === "1") {
process.exit(0);
}

// The per-actor inspector UI (frontend/dist/inspector-ui, embedded into
// rivetkit-core by its build.rs) must be built before this napi build runs.
// It is NOT built here: rivetkit-core's embed needs rivetkit/inspector-tab,
// which is downstream of this package in the build graph, so building it from
// the napi build would invert the dependency order. CI builds it via
// `turbo build:inspector-ui` in docker/build/*.Dockerfile before `napi build`;
// for local builds run `pnpm -F @rivetkit/engine-frontend build:inspector-ui`
// (or `turbo build:inspector-ui`) first.
const cmd = ["build", "--platform", ...extraFlags];
console.log(`[rivetkit-napi/build] running: napi ${cmd.join(" ")}`);
execFileSync("napi", cmd, { stdio: "inherit" });
23 changes: 20 additions & 3 deletions rivetkit-typescript/packages/rivetkit/src/registry/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4756,12 +4756,29 @@ export async function buildServeConfig(
serverlessMaxStartPayloadBytes: config.serverless.maxStartPayloadBytes,
};

if (config.startEngine) {
// Always best-effort resolve the npm-installed engine binary and hand its
// path to the core. The core alone decides whether to actually spawn a local
// engine (its `should_manage_engine`, based on the endpoint + spawn mode), so
// JS must not duplicate that decision here. Only JS knows the npm
// `node_modules` layout, so it resolves the path; if no binary is available
// (remote-only install, unsupported platform, optional deps skipped), leave
// it unset and let the core report `engine.binary_unavailable` if it actually
// needs one.
try {
const { getEnginePath } = await loadEngineCli();
serveConfig.engineBinaryPath = getEnginePath();
serveConfig.engineHost = config.engineHost;
serveConfig.enginePort = config.enginePort;
} catch (error) {
// The npm-installed engine binary could not be resolved. The core still
// decides whether it needs to spawn a local engine; if it does, it will
// fail with engine.binary_unavailable (auto-download is off in the napi
// runtime). Warn so the cause is actionable.
logger().warn({
msg: "could not resolve a local engine binary; if a local engine must be spawned it will fail with engine.binary_unavailable — set RIVET_ENGINE_BINARY_PATH or install the @rivetkit/engine-cli platform package",
error: stringifyError(error),
});
}
serveConfig.engineHost = config.engineHost;
serveConfig.enginePort = config.enginePort;
if (config.test?.enabled) {
serveConfig.inspectorTestToken =
getEnvUniversal("_RIVET_TEST_INSPECTOR_TOKEN") ?? "token";
Expand Down
22 changes: 19 additions & 3 deletions rivetkit-typescript/packages/rivetkit/src/registry/runtime.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { stringifyError } from "@/common/utils";
import type { SqliteNativeMetrics } from "@/common/database/config";
import type { RegistryConfig } from "./config";
import { logger } from "./log";

declare const handleBrand: unique symbol;

Expand Down Expand Up @@ -599,11 +601,25 @@ export async function buildServeConfig(
serverlessMaxStartPayloadBytes: config.serverless.maxStartPayloadBytes,
};

if (config.startEngine) {
// Always best-effort resolve the engine binary path and hand it to the core.
// The core alone decides whether to actually spawn a local engine, so JS must
// not duplicate that decision here. `loadEnginePath` throws when no binary is
// available (remote-only install, unsupported platform, optional deps
// skipped); in that case leave it unset and let the core report
// `engine.binary_unavailable` only if it actually needs one.
try {
serveConfig.engineBinaryPath = await loadEnginePath();
serveConfig.engineHost = config.engineHost;
serveConfig.enginePort = config.enginePort;
} catch (error) {
// The engine binary could not be resolved. The core still decides whether
// it needs to spawn a local engine; if it does, it will fail with
// engine.binary_unavailable (auto-download is off in the napi runtime).
logger().warn({
msg: "could not resolve a local engine binary; if a local engine must be spawned it will fail with engine.binary_unavailable — set RIVET_ENGINE_BINARY_PATH or install the @rivetkit/engine-cli platform package",
error: stringifyError(error),
});
}
serveConfig.engineHost = config.engineHost;
serveConfig.enginePort = config.enginePort;
if (config.test?.enabled) {
serveConfig.inspectorTestToken =
process.env._RIVET_TEST_INSPECTOR_TOKEN ?? "token";
Expand Down
8 changes: 7 additions & 1 deletion scripts/publish/src/ci/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,21 @@ const RUST_CRATES = [
"rivet-error",
"rivet-metrics",
"rivet-util-serde",
// rivet-envoy-protocol must precede rivet-depot-client, which pins it as an
// exact dependency. Publishing depot-client first makes cargo fail to
// resolve rivet-envoy-protocol because it is not yet on crates.io.
"rivet-envoy-protocol",
"rivet-depot-client-types",
"rivet-depot-client",
"rivet-envoy-protocol",
"rivetkit-shared-types",
"rivet-envoy-client",
"rivetkit-actor-persist",
"rivetkit-client-protocol",
"rivetkit-inspector-protocol",
"rivetkit-client",
// rivetkit-core has an optional dependency on rivetkit-engine-process, which
// cargo still requires to be resolvable on crates.io at publish time.
"rivetkit-engine-process",
"rivetkit-core",
"rivetkit",
] as const;
Expand Down
8 changes: 6 additions & 2 deletions scripts/publish/src/lib/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,12 @@ export async function publishAll(
counts.failed === 0 &&
counts.alreadyExists === packages.length
) {
throw new Error(
`release mode: all ${packages.length} packages already published at this version. Did you forget to bump the version?`,
// This usually means a forgotten version bump, but it also happens on a
// legitimate re-run after npm fully published and a later pipeline step
// (crates.io, git tag, GitHub release) failed. Warn instead of failing so
// the re-run can reach those downstream steps; they are idempotent.
log.warn(
`release mode: all ${packages.length} packages already published at this version. Continuing (assuming a re-run); ensure the version was bumped.`,
);
}

Expand Down
1 change: 1 addition & 0 deletions scripts/publish/src/lib/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const PUBLISHED_RUST_WORKSPACE_DEPS = new Set([
"rivetkit-inspector-protocol",
"rivetkit-client",
"rivetkit-core",
"rivetkit-engine-process",
]);

export interface BumpOptions {
Expand Down
9 changes: 9 additions & 0 deletions scripts/publish/src/local/cut-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { Command } from "commander";
import { $ } from "execa";
import { scoped } from "../lib/logger.js";
import {
bumpCargoVersions,
bumpPackageJsons,
getLatestGitVersion,
listRecentVersions,
Expand Down Expand Up @@ -137,6 +138,14 @@ async function main() {
log.info("updating source files (Cargo.toml, examples)");
await updateSourceFiles(repoRoot, version);

// Bump the Cargo.toml workspace dependency pins (the `version = "=X"`
// exact pins on internal crates). updateSourceFiles only rewrites the
// [workspace.package] version, so without this the internal crate pins
// stay on the previous version and the Rust/wasm build fails to resolve.
// Always writes (like updateSourceFiles); dry-run still mutates source
// files and only skips the commit/push/trigger tail.
await bumpCargoVersions(repoRoot, version);

// 6. Rewrite package.json version fields via discovery. Uses versionOnly
// mode so `workspace:*` dep specs are preserved — the lockfile depends on
// them. CI runs the full publish-time bump (with dep rewriting +
Expand Down
12 changes: 12 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@
"outputs": ["dist/**"],
"env": ["BASE_URL", "VITE_APP_*", "VITE_FEATURE_FLAGS"]
},
"build:inspector-ui": {
"dependsOn": ["^build"],
"inputs": [
"src/**",
"apps/inspector-ui/**",
"scripts/**",
"vite.inspector-ui.config.ts",
"tsconfig.json",
"package.json"
],
"outputs": ["dist/inspector-ui/**", "dist/inspector-tab/**"]
},
"build:ladle": {
"dependsOn": ["^build"],
"inputs": [
Expand Down
Loading