Skip to content

Remove experimental bun support #2048

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
7 changes: 7 additions & 0 deletions .changeset/mighty-dryers-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"trigger.dev": patch
"@trigger.dev/core": patch
"@trigger.dev/rsc": patch
---

Remove experimental `bun` support. `node` is now the only supported runtime.
4 changes: 2 additions & 2 deletions .cursor/rules/writing-tasks.mdc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
globs: **/trigger/**/*.ts, **/trigger/**/*.tsx,**/trigger/**/*.js,**/trigger/**/*.jsx
description: Guidelines for writing Trigger.dev tasks
globs: **/trigger/**/*.ts, **/trigger/**/*.tsx,**/trigger/**/*.js,**/trigger/**/*.jsx
alwaysApply: false
---
# How to write Trigger.dev tasks
Expand Down Expand Up @@ -1165,7 +1165,7 @@ telemetry: {
Specify the runtime environment:

```ts
runtime: "node", // or "bun" (experimental)
runtime: "node",
```

#### Machine settings
Expand Down
16 changes: 0 additions & 16 deletions docs/config/config-file.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,6 @@ export default defineConfig({

Make sure to set the `AXIOM_API_TOKEN` and `AXIOM_DATASET` environment variables in your project.

## Runtime

We currently only officially support the `node` runtime, but you can try our experimental `bun` runtime by setting the `runtime` option in your config file:

```ts trigger.config.ts
import { defineConfig } from "@trigger.dev/sdk/v3";

export default defineConfig({
project: "<project ref>",
// Your other config settings...
runtime: "bun",
});
```

See our [Bun guide](/guides/frameworks/bun) for more information.

## Default machine

You can specify the default machine for all tasks in your project:
Expand Down
2 changes: 1 addition & 1 deletion docs/config/extensions/custom.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ const resolvedPath = context.resolvePath("my-other-dependency");
<ParamField path="config" type="ResolvedConfig">
<Expandable title="properties">
<ResponseField name="runtime" type="string">
The runtime of the project (either node or bun)
The runtime of the project (only `node` is supported currently)
</ResponseField>
<ResponseField name="project" type="string">
The project ref
Expand Down
1 change: 0 additions & 1 deletion docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@
{
"group": "Frameworks",
"pages": [
"guides/frameworks/bun",
"guides/frameworks/nextjs",
"guides/frameworks/nodejs",
"guides/frameworks/remix",
Expand Down
115 changes: 0 additions & 115 deletions docs/guides/frameworks/bun.mdx

This file was deleted.

1 change: 0 additions & 1 deletion docs/guides/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ mode: "center"
## Frameworks

<CardGroup cols={3}>
<Card title="Bun" img="/images/logo-bun.png" href="/guides/frameworks/bun" />
<Card title="Next.js" img="/images/logo-nextjs.png" href="/guides/frameworks/nextjs" />
<Card title="Node.js" img="/images/logo-nodejs.png" href="/guides/frameworks/nodejs" />
<Card title="Remix" img="/images/logo-remix.png" href="/guides/frameworks/remix" />
Expand Down
4 changes: 4 additions & 0 deletions docs/upgrade-to-v4.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -860,3 +860,7 @@ const batchHandle = await tasks.batchTrigger([
const runs = await batchHandle.runs.list();
console.log(runs);
```

### Runtime changes

We've removed experimental support for the `bun` runtime. The only supported runtime is now `node`.
5 changes: 0 additions & 5 deletions packages/cli-v3/src/build/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { BuildTarget } from "@trigger.dev/core/v3/schemas";
import { ResolvedConfig } from "@trigger.dev/core/v3/build";
import { configPlugin } from "../config.js";
import { logger } from "../utilities/logger.js";
import { bunPlugin } from "../runtimes/bun.js";
import { resolvePathSync as esmResolveSync } from "mlly";
import { readPackageJSON, resolvePackageJSON } from "pkg-types";
import { dirname } from "node:path";
Expand All @@ -25,10 +24,6 @@ export async function buildPlugins(

plugins.push(polyshedPlugin());

if (resolvedConfig.runtime === "bun") {
plugins.push(bunPlugin());
}

return plugins;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cli-v3/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function configureInitCommand(program: Command) {
)
.option(
"-r, --runtime <runtime>",
"Which runtime to use for the project. Currently only supports node and bun",
"Which runtime to use for the project. Currently only supports node.",
"node"
)
.option("--skip-package-install", "Skip installing the @trigger.dev/sdk package")
Expand Down
7 changes: 2 additions & 5 deletions packages/cli-v3/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,8 @@ function validateConfig(config: TriggerConfig, warn = true) {
);
}

if (config.runtime && config.runtime === "bun") {
warn &&
prettyWarning(
`The "bun" runtime is currently experimental, and certain features may not work, especially opentelemetry instrumentation of 3rd party packages.`
);
if (config.runtime && (config.runtime as string) === "bun") {
throw new Error("Bun support was removed in v4. Please use the `node` runtime instead.");
}
}

Expand Down
114 changes: 8 additions & 106 deletions packages/cli-v3/src/deploy/buildImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,24 +473,24 @@ export type GenerateContainerfileOptions = {
entrypoint: string;
};

const NODE_21_IMAGE =
"node:21.7.3-bookworm-slim@sha256:dfc05dee209a1d7adf2ef189bd97396daad4e97c6eaa85778d6f75205ba1b0fb";

const NODE_TEST_IMAGE = NODE_21_IMAGE;

const BASE_IMAGE: Record<BuildRuntime, string> = {
bun: "imbios/bun-node:1.2.1-22-slim@sha256:6c31db8f11f0d37357ef8156c2dab684448b54a1fb50ca1c22bca82bce76c788",
node: "node:21.7.3-bookworm-slim@sha256:dfc05dee209a1d7adf2ef189bd97396daad4e97c6eaa85778d6f75205ba1b0fb",
"node-22":
"node:22.12.0-bookworm-slim@sha256:a4b757cd491c7f0b57f57951f35f4e85b7e1ad54dbffca4cf9af0725e1650cd8",
node: NODE_21_IMAGE,
"node-test": NODE_TEST_IMAGE,
};

const DEFAULT_PACKAGES = ["busybox", "ca-certificates", "dumb-init", "git", "openssl"];

export async function generateContainerfile(options: GenerateContainerfileOptions) {
switch (options.runtime) {
case "node":
case "node-22": {
case "node-test": {
return await generateNodeContainerfile(options);
}
case "bun": {
return await generateBunContainerfile(options);
}
}
}

Expand Down Expand Up @@ -520,104 +520,6 @@ const parseGenerateOptions = (options: GenerateContainerfileOptions) => {
};
};

async function generateBunContainerfile(options: GenerateContainerfileOptions) {
const { baseImage, buildArgs, buildEnvVars, postInstallCommands, baseInstructions, packages } =
parseGenerateOptions(options);

return `# syntax=docker/dockerfile:1
FROM ${baseImage} AS base

${baseInstructions}

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get --fix-broken install -y && \
apt-get install -y --no-install-recommends ${packages} && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

FROM base AS build

RUN apt-get update && \
apt-get install -y --no-install-recommends python3 make g++ && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

USER bun
WORKDIR /app

${buildArgs}

${buildEnvVars}

COPY --chown=bun:bun package.json ./
RUN bun install --production --no-save

# Now copy all the files
# IMPORTANT: Do this after running npm install because npm i will wipe out the node_modules directory
COPY --chown=bun:bun . .

${postInstallCommands}

FROM build AS indexer

USER bun
WORKDIR /app

ARG TRIGGER_PROJECT_ID
ARG TRIGGER_DEPLOYMENT_ID
ARG TRIGGER_DEPLOYMENT_VERSION
ARG TRIGGER_CONTENT_HASH
ARG TRIGGER_PROJECT_REF
ARG NODE_EXTRA_CA_CERTS
ARG TRIGGER_SECRET_KEY
ARG TRIGGER_API_URL

ENV TRIGGER_PROJECT_ID=\${TRIGGER_PROJECT_ID} \
TRIGGER_DEPLOYMENT_ID=\${TRIGGER_DEPLOYMENT_ID} \
TRIGGER_DEPLOYMENT_VERSION=\${TRIGGER_DEPLOYMENT_VERSION} \
TRIGGER_PROJECT_REF=\${TRIGGER_PROJECT_REF} \
TRIGGER_CONTENT_HASH=\${TRIGGER_CONTENT_HASH} \
TRIGGER_SECRET_KEY=\${TRIGGER_SECRET_KEY} \
TRIGGER_API_URL=\${TRIGGER_API_URL} \
NODE_EXTRA_CA_CERTS=\${NODE_EXTRA_CA_CERTS} \
NODE_ENV=production

# Run the indexer
RUN bun run ${options.indexScript}

# Development or production stage builds upon the base stage
FROM base AS final

USER bun
WORKDIR /app

ARG TRIGGER_PROJECT_ID
ARG TRIGGER_DEPLOYMENT_ID
ARG TRIGGER_DEPLOYMENT_VERSION
ARG TRIGGER_CONTENT_HASH
ARG TRIGGER_PROJECT_REF
ARG NODE_EXTRA_CA_CERTS

ENV TRIGGER_PROJECT_ID=\${TRIGGER_PROJECT_ID} \
TRIGGER_DEPLOYMENT_ID=\${TRIGGER_DEPLOYMENT_ID} \
TRIGGER_DEPLOYMENT_VERSION=\${TRIGGER_DEPLOYMENT_VERSION} \
TRIGGER_CONTENT_HASH=\${TRIGGER_CONTENT_HASH} \
TRIGGER_PROJECT_REF=\${TRIGGER_PROJECT_REF} \
NODE_EXTRA_CA_CERTS=\${NODE_EXTRA_CA_CERTS} \
NODE_ENV=production

# Copy the files from the build stage
COPY --from=build --chown=bun:bun /app ./

# Copy the index.json file from the indexer stage
COPY --from=indexer --chown=bun:bun /app/index.json ./

ENTRYPOINT [ "dumb-init", "node", "${options.entrypoint}" ]
CMD []
`;
}

async function generateNodeContainerfile(options: GenerateContainerfileOptions) {
const { baseImage, buildArgs, buildEnvVars, postInstallCommands, baseInstructions, packages } =
parseGenerateOptions(options);
Expand Down
1 change: 0 additions & 1 deletion packages/cli-v3/src/executions/taskRunProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ export class TaskRunProcess {
const fullEnv = {
...$env,
OTEL_IMPORT_HOOK_INCLUDES: workerManifest.otelImportHook?.include?.join(","),
// TODO: this will probably need to use something different for bun (maybe --preload?)
NODE_OPTIONS: execOptionsForRuntime(workerManifest.runtime, workerManifest, maxOldSpaceSize),
PATH: process.env.PATH,
TRIGGER_PROCESS_FORK_START_TIME: String(Date.now()),
Expand Down
12 changes: 0 additions & 12 deletions packages/cli-v3/src/runtimes/bun.ts

This file was deleted.

Loading