From cc0321d7e385bc5f71c9d16e41e885ad11bbf853 Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Wed, 14 May 2025 11:36:48 +0100 Subject: [PATCH 1/5] remove experimental bun support --- .cursor/rules/writing-tasks.mdc | 4 +- docs/config/config-file.mdx | 16 --- docs/config/extensions/custom.mdx | 2 +- docs/docs.json | 1 - docs/guides/frameworks/bun.mdx | 115 ------------------ docs/guides/introduction.mdx | 1 - packages/cli-v3/src/build/plugins.ts | 5 - packages/cli-v3/src/commands/init.ts | 2 +- packages/cli-v3/src/config.ts | 7 +- packages/cli-v3/src/deploy/buildImage.ts | 102 ---------------- .../cli-v3/src/executions/taskRunProcess.ts | 1 - packages/cli-v3/src/runtimes/bun.ts | 12 -- packages/core/src/v3/build/runtime.ts | 15 --- packages/core/src/v3/schemas/build.ts | 2 +- packages/rsc/src/build.ts | 3 +- pnpm-lock.yaml | 33 +---- references/bun-catalog/.env.example | 3 - references/bun-catalog/.gitignore | 1 - references/bun-catalog/README.md | 59 --------- references/bun-catalog/package.json | 16 --- references/bun-catalog/src/trigger/bun.ts | 16 --- references/bun-catalog/trigger.config.ts | 26 ---- references/bun-catalog/tsconfig.json | 20 --- 23 files changed, 9 insertions(+), 453 deletions(-) delete mode 100644 docs/guides/frameworks/bun.mdx delete mode 100644 packages/cli-v3/src/runtimes/bun.ts delete mode 100644 references/bun-catalog/.env.example delete mode 100644 references/bun-catalog/.gitignore delete mode 100644 references/bun-catalog/README.md delete mode 100644 references/bun-catalog/package.json delete mode 100644 references/bun-catalog/src/trigger/bun.ts delete mode 100644 references/bun-catalog/trigger.config.ts delete mode 100644 references/bun-catalog/tsconfig.json diff --git a/.cursor/rules/writing-tasks.mdc b/.cursor/rules/writing-tasks.mdc index 6090b85f09..b01937dae8 100644 --- a/.cursor/rules/writing-tasks.mdc +++ b/.cursor/rules/writing-tasks.mdc @@ -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 @@ -1165,7 +1165,7 @@ telemetry: { Specify the runtime environment: ```ts -runtime: "node", // or "bun" (experimental) +runtime: "node", ``` #### Machine settings diff --git a/docs/config/config-file.mdx b/docs/config/config-file.mdx index 0a8e3ba66a..731116e87e 100644 --- a/docs/config/config-file.mdx +++ b/docs/config/config-file.mdx @@ -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: "", - // 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: diff --git a/docs/config/extensions/custom.mdx b/docs/config/extensions/custom.mdx index 2d581c6545..4d89a101c0 100644 --- a/docs/config/extensions/custom.mdx +++ b/docs/config/extensions/custom.mdx @@ -250,7 +250,7 @@ const resolvedPath = context.resolvePath("my-other-dependency"); - The runtime of the project (either node or bun) + The runtime of the project (only `node` is supported currently) The project ref diff --git a/docs/docs.json b/docs/docs.json index e9352be310..622bb4e75b 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -252,7 +252,6 @@ { "group": "Frameworks", "pages": [ - "guides/frameworks/bun", "guides/frameworks/nextjs", "guides/frameworks/nodejs", "guides/frameworks/remix", diff --git a/docs/guides/frameworks/bun.mdx b/docs/guides/frameworks/bun.mdx deleted file mode 100644 index 380ebcdc1d..0000000000 --- a/docs/guides/frameworks/bun.mdx +++ /dev/null @@ -1,115 +0,0 @@ ---- -title: "Bun guide" -sidebarTitle: "Bun" -description: "This guide will show you how to setup Trigger.dev with Bun" -icon: "js" ---- - -import Prerequisites from "/snippets/framework-prerequisites.mdx"; -import CliRunTestStep from "/snippets/step-run-test.mdx"; -import CliViewRunStep from "/snippets/step-view-run.mdx"; - -A specific Bun version is currently required for the dev command to work. This is due to a [bug](https://github.com/oven-sh/bun/issues/13799) with IPC. Please use Bun version 1.1.24 or lower: `curl -fsSL https://bun.sh/install | bash -s -- bun-v1.1.24` - -We now have experimental support for Bun. This guide will show you have to setup Trigger.dev in your existing Bun project, test an example task, and view the run. - - - The trigger.dev CLI does not yet support Bun. So you will need to run the CLI using Node.js. But - Bun will still be used to execute your tasks, even in the `dev` environment. - - - - -## Initial setup - - - - -The easiest way to get started is to use the CLI. It will add Trigger.dev to your existing project, create a `/trigger` folder and give you an example task. - -Run this command in the root of your project to get started: - - - -```bash npm -npx trigger.dev@latest init --runtime bun -``` - -```bash pnpm -pnpm dlx trigger.dev@latest init --runtime bun -``` - -```bash yarn -yarn dlx trigger.dev@latest init --runtime bun -``` - - - -It will do a few things: - -1. Log you into the CLI if you're not already logged in. -2. Create a `trigger.config.ts` file in the root of your project. -3. Ask where you'd like to create the `/trigger` directory. -4. Create the `/src/trigger` directory with an example task, `/src/trigger/example.[ts/js]`. - -Install the "Hello World" example task when prompted. We'll use this task to test the setup. - - - - - - Open the `/src/trigger/example.ts` file and replace the contents with the following: - - ```ts example.ts - import { Database } from "bun:sqlite"; - import { task } from "@trigger.dev/sdk/v3"; - - export const bunTask = task({ - id: "bun-task", - run: async (payload: { query: string }) => { - const db = new Database(":memory:"); - const query = db.query("select 'Hello world' as message;"); - console.log(query.get()); // => { message: "Hello world" } - - return { - message: "Query executed", - }; - }, - }); - - ``` - - - - - -The CLI `dev` command runs a server for your tasks. It watches for changes in your `/trigger` directory and communicates with the Trigger.dev platform to register your tasks, perform runs, and send data back and forth. - -It can also update your `@trigger.dev/*` packages to prevent version mismatches and failed deploys. You will always be prompted first. - - - -```bash npm -npx trigger.dev@latest dev -``` - -```bash pnpm -pnpm dlx trigger.dev@latest dev -``` - -```bash yarn -yarn dlx trigger.dev@latest dev -``` - - - - - - - - - - -## Known issues - -- Certain OpenTelemetry instrumentation will not work with Bun, because Bun does not support Node's `register` hook. This means that some libraries that rely on this hook will not work with Bun. diff --git a/docs/guides/introduction.mdx b/docs/guides/introduction.mdx index 9a7e7761eb..c2a2d5ec51 100644 --- a/docs/guides/introduction.mdx +++ b/docs/guides/introduction.mdx @@ -8,7 +8,6 @@ mode: "center" ## Frameworks - diff --git a/packages/cli-v3/src/build/plugins.ts b/packages/cli-v3/src/build/plugins.ts index 81a1cecea4..5661381c82 100644 --- a/packages/cli-v3/src/build/plugins.ts +++ b/packages/cli-v3/src/build/plugins.ts @@ -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"; @@ -25,10 +24,6 @@ export async function buildPlugins( plugins.push(polyshedPlugin()); - if (resolvedConfig.runtime === "bun") { - plugins.push(bunPlugin()); - } - return plugins; } diff --git a/packages/cli-v3/src/commands/init.ts b/packages/cli-v3/src/commands/init.ts index fcae774961..f6d13c1515 100644 --- a/packages/cli-v3/src/commands/init.ts +++ b/packages/cli-v3/src/commands/init.ts @@ -68,7 +68,7 @@ export function configureInitCommand(program: Command) { ) .option( "-r, --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") diff --git a/packages/cli-v3/src/config.ts b/packages/cli-v3/src/config.ts index 8cca2d1605..d92e8fa6f8 100644 --- a/packages/cli-v3/src/config.ts +++ b/packages/cli-v3/src/config.ts @@ -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."); } } diff --git a/packages/cli-v3/src/deploy/buildImage.ts b/packages/cli-v3/src/deploy/buildImage.ts index 73e377796a..bf2b937fb1 100644 --- a/packages/cli-v3/src/deploy/buildImage.ts +++ b/packages/cli-v3/src/deploy/buildImage.ts @@ -474,7 +474,6 @@ export type GenerateContainerfileOptions = { }; const BASE_IMAGE: Record = { - 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", @@ -488,9 +487,6 @@ export async function generateContainerfile(options: GenerateContainerfileOption case "node-22": { return await generateNodeContainerfile(options); } - case "bun": { - return await generateBunContainerfile(options); - } } } @@ -520,104 +516,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); diff --git a/packages/cli-v3/src/executions/taskRunProcess.ts b/packages/cli-v3/src/executions/taskRunProcess.ts index 6821fbdfc9..b8f0f07800 100644 --- a/packages/cli-v3/src/executions/taskRunProcess.ts +++ b/packages/cli-v3/src/executions/taskRunProcess.ts @@ -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()), diff --git a/packages/cli-v3/src/runtimes/bun.ts b/packages/cli-v3/src/runtimes/bun.ts deleted file mode 100644 index 79cdb2ab44..0000000000 --- a/packages/cli-v3/src/runtimes/bun.ts +++ /dev/null @@ -1,12 +0,0 @@ -import * as esbuild from "esbuild"; - -export function bunPlugin(): esbuild.Plugin { - return { - name: "bun", - setup(build) { - build.onResolve({ filter: /^bun:/ }, (args) => { - return { path: args.path, external: true }; - }); - }, - }; -} diff --git a/packages/core/src/v3/build/runtime.ts b/packages/core/src/v3/build/runtime.ts index dc8ce19c6c..28a3fabbe3 100644 --- a/packages/core/src/v3/build/runtime.ts +++ b/packages/core/src/v3/build/runtime.ts @@ -10,8 +10,6 @@ export function binaryForRuntime(runtime: BuildRuntime): string { case "node": case "node-22": return "node"; - case "bun": - return "bun"; default: throw new Error(`Unsupported runtime ${runtime}`); } @@ -22,16 +20,6 @@ export function execPathForRuntime(runtime: BuildRuntime): string { case "node": case "node-22": return process.execPath; - case "bun": - if (typeof process.env.BUN_INSTALL === "string") { - return join(process.env.BUN_INSTALL, "bin", "bun"); - } - - if (typeof process.env.BUN_INSTALL_BIN === "string") { - return join(process.env.BUN_INSTALL_BIN, "bun"); - } - - return join("~", ".bin", "bin", "bun"); default: throw new Error(`Unsupported runtime ${runtime}`); } @@ -70,9 +58,6 @@ export function execOptionsForRuntime( return dedupFlags(flags); } - case "bun": { - return ""; - } } } diff --git a/packages/core/src/v3/schemas/build.ts b/packages/core/src/v3/schemas/build.ts index c3df04eaa7..2dda9a6be8 100644 --- a/packages/core/src/v3/schemas/build.ts +++ b/packages/core/src/v3/schemas/build.ts @@ -13,7 +13,7 @@ export const BuildTarget = z.enum(["dev", "deploy", "unmanaged"]); export type BuildTarget = z.infer; -export const BuildRuntime = z.enum(["node", "node-22", "bun"]); +export const BuildRuntime = z.enum(["node", "node-22"]); export type BuildRuntime = z.infer; diff --git a/packages/rsc/src/build.ts b/packages/rsc/src/build.ts index 5436bf6fb0..d747cf2584 100644 --- a/packages/rsc/src/build.ts +++ b/packages/rsc/src/build.ts @@ -89,8 +89,7 @@ export function rscExtension(options?: RSCExtensionOptions): BuildExtension { }); build.onResolve({ filter: /^react-dom\/server$/ }, (args) => { - const condition = - context.config.runtime === "bun" ? "bun" : options?.reactDomEnvironment ?? "node"; + const condition = options?.reactDomEnvironment ?? "node"; context.logger.debug("Resolving react-dom/server", { args, condition }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9ed8e79845..49f4b9fb8b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1804,19 +1804,6 @@ importers: specifier: 3.23.8 version: 3.23.8 - references/bun-catalog: - dependencies: - '@trigger.dev/sdk': - specifier: workspace:* - version: link:../../packages/trigger-sdk - devDependencies: - '@types/bun': - specifier: ^1.1.6 - version: 1.1.6 - trigger.dev: - specifier: workspace:* - version: link:../../packages/cli-v3 - references/d3-chat: dependencies: '@ai-sdk/anthropic': @@ -18118,12 +18105,6 @@ packages: '@types/node': 20.14.14 dev: true - /@types/bun@1.1.6: - resolution: {integrity: sha512-uJgKjTdX0GkWEHZzQzFsJkWp5+43ZS7HC8sZPFnOwnSo1AsNl2q9o2bFeS23disNDqbggEgyFkKCHl/w8iZsMA==} - dependencies: - bun-types: 1.1.17 - dev: true - /@types/caseless@0.12.5: resolution: {integrity: sha512-hWtVTC2q7hc7xZ/RLbxapMvDMgUnDvKvMOpKal4DrMyfGBUfB1oKaZlIRr6mJL+If3bAP6sV/QneGzF6tJjZDg==} dev: false @@ -18501,12 +18482,6 @@ packages: undici-types: 5.26.5 dev: false - /@types/node@20.12.14: - resolution: {integrity: sha512-scnD59RpYD91xngrQQLGkE+6UrHUPzeKZWhhjBSa3HSkwjbQc38+q3RoIVEwxQGRw3M+j5hpNAM+lgV3cVormg==} - dependencies: - undici-types: 5.26.5 - dev: true - /@types/node@20.14.14: resolution: {integrity: sha512-d64f00982fS9YoOgJkAMolK7MN8Iq3TDdVjchbYHdEmjth/DHowx82GnoA+tVUAN+7vxfYUgAzi+JXbKNd2SDQ==} dependencies: @@ -18804,6 +18779,7 @@ packages: resolution: {integrity: sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==} dependencies: '@types/node': 20.14.14 + dev: false /@types/ws@8.5.12: resolution: {integrity: sha512-3tPRkv1EtkDpzlgyKyI8pGsGZAGPEaXeu0DOj5DI25Ja91bdAYddYHbADRYVrZMRbfW+1l5YwXVDKohDJNQxkQ==} @@ -21027,13 +21003,6 @@ packages: semver: 7.6.3 dev: true - /bun-types@1.1.17: - resolution: {integrity: sha512-Z4+OplcSd/YZq7ZsrfD00DKJeCwuNY96a1IDJyR73+cTBaFIS7SC6LhpY/W3AMEXO9iYq5NJ58WAwnwL1p5vKg==} - dependencies: - '@types/node': 20.12.14 - '@types/ws': 8.5.10 - dev: true - /bundle-name@4.1.0: resolution: {integrity: sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q==} engines: {node: '>=18'} diff --git a/references/bun-catalog/.env.example b/references/bun-catalog/.env.example deleted file mode 100644 index 9001181b66..0000000000 --- a/references/bun-catalog/.env.example +++ /dev/null @@ -1,3 +0,0 @@ -TRIGGER_SECRET_KEY= -TRIGGER_API_URL= -OPENAI_API_KEY="My API Key" \ No newline at end of file diff --git a/references/bun-catalog/.gitignore b/references/bun-catalog/.gitignore deleted file mode 100644 index 6524f048dc..0000000000 --- a/references/bun-catalog/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.trigger \ No newline at end of file diff --git a/references/bun-catalog/README.md b/references/bun-catalog/README.md deleted file mode 100644 index b3e0768da1..0000000000 --- a/references/bun-catalog/README.md +++ /dev/null @@ -1,59 +0,0 @@ -# The v3 catalog - -You can test v3 tasks from inside the app in this project. It's designed to be used for testing features and functionality of the v3 SDK. - -## One-time setup - -1. In Postgres go to the "Organizations" table and on your org set the `v3Enabled` column to `true`. - -2. Create a v3 project in the UI of the webapp, you should now be able to select it from the dropdown. - -3. In Postgres go to the "Projects" table and for the project you create change the `externalRef` to `yubjwjsfkxnylobaqvqz`. - -This is so the `trigger.config.ts` file inside the v3-catalog doesn't keep getting changed by people accidentally pushing this. - -## How to use - -1. Make sure you're running the main webapp - -```bash -pnpm run dev --filter webapp -``` - -2. Build the v3 CLI (this needs to be done everytime a code changes is made to the CLI if you're working on it) - -```bash -pnpm run build --filter trigger.dev -``` - -3. CD into the v3-catalog directory - -```bash -cd references/v3-catalog -``` - -4. If you've never logged in to the CLI you'll see an error telling you to login. Do this: - -```bash -pnpm exec trigger login -a http://localhost:3030 -``` - -If this fails because you already are logged in you can create a new profile: - -```bash -pnpm exec trigger login -a http://localhost:3030 --profile local -``` - -Note: if you use a profile then you'll need to append `--profile local` to all commands, like `dev`. - -5. Run the v3 CLI - -```bash -pnpm exec trigger dev -``` - -6. You should see the v3 dev command spitting out messages, including that it's started a background worker. - -7. Go to the webapp now and inside your project you should see some tasks on the "Tasks" page. - -8. Go to the "Test" page in the sidebar and select a task. Then enter a payload and click "Run test". You can tell what the payloads should be by looking at the relevant task file inside the `/references/v3-catalog/src/trigger` folder. Many of them accept an empty payload. diff --git a/references/bun-catalog/package.json b/references/bun-catalog/package.json deleted file mode 100644 index 519296c6ca..0000000000 --- a/references/bun-catalog/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "references-bun-catalog", - "private": true, - "type": "module", - "scripts": { - "dev:trigger": "trigger dev", - "deploy": "trigger deploy" - }, - "dependencies": { - "@trigger.dev/sdk": "workspace:*" - }, - "devDependencies": { - "@types/bun": "^1.1.6", - "trigger.dev": "workspace:*" - } -} \ No newline at end of file diff --git a/references/bun-catalog/src/trigger/bun.ts b/references/bun-catalog/src/trigger/bun.ts deleted file mode 100644 index ef6e8d9f25..0000000000 --- a/references/bun-catalog/src/trigger/bun.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Database } from "bun:sqlite"; -import { task } from "@trigger.dev/sdk/v3"; - -export const bunTask = task({ - id: "bun-task", - run: async (payload: { query: string }) => { - const db = new Database(":memory:"); - const query = db.query("select 'Hello world' as message;"); - console.log(query.get()); // => { message: "Hello world" } - - return { - message: "Query executed", - bunVersion: Bun.version, - }; - }, -}); diff --git a/references/bun-catalog/trigger.config.ts b/references/bun-catalog/trigger.config.ts deleted file mode 100644 index a2deb7398e..0000000000 --- a/references/bun-catalog/trigger.config.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { defineConfig } from "@trigger.dev/sdk/v3"; - -export default defineConfig({ - runtime: "bun", - project: "proj_uxbxncnbsyamyxeqtucu", - maxDuration: 3600, - machine: "small-2x", - retries: { - enabledInDev: true, - default: { - maxAttempts: 4, - minTimeoutInMs: 10000, - maxTimeoutInMs: 10000, - factor: 2, - randomize: true, - }, - }, - enableConsoleLogging: false, - logLevel: "info", - onStart: async (payload, { ctx }) => { - console.log(`Task ${ctx.task.id} started ${ctx.run.id}`); - }, - onFailure: async (payload, error, { ctx }) => { - console.log(`Task ${ctx.task.id} failed ${ctx.run.id}`); - }, -}); diff --git a/references/bun-catalog/tsconfig.json b/references/bun-catalog/tsconfig.json deleted file mode 100644 index 635ecdb766..0000000000 --- a/references/bun-catalog/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "target": "esnext", - "module": "NodeNext", - "moduleResolution": "NodeNext", - "esModuleInterop": true, - "strict": true, - "outDir": "dist", - "skipLibCheck": true, - "customConditions": ["@triggerdotdev/source"], - "jsx": "preserve", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "lib": ["DOM", "DOM.Iterable"], - "paths": { - "@/*": ["./src/*"] - } - }, - "include": ["./src/**/*.ts", "trigger.config.ts"] -} From db20714c718d02c0a7ddb3f8c91578a613775822 Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Wed, 14 May 2025 11:37:34 +0100 Subject: [PATCH 2/5] add changeset --- .changeset/mighty-dryers-warn.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/mighty-dryers-warn.md diff --git a/.changeset/mighty-dryers-warn.md b/.changeset/mighty-dryers-warn.md new file mode 100644 index 0000000000..cc012d2d07 --- /dev/null +++ b/.changeset/mighty-dryers-warn.md @@ -0,0 +1,7 @@ +--- +"trigger.dev": patch +"@trigger.dev/core": patch +"@trigger.dev/rsc": patch +--- + +Remove experimental Bun support From 4f38f2002432522589870668dae516074758fd78 Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Wed, 14 May 2025 11:44:51 +0100 Subject: [PATCH 3/5] add breaking change to docs --- docs/upgrade-to-v4.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/upgrade-to-v4.mdx b/docs/upgrade-to-v4.mdx index 03a8ba6b1a..f8d41a23a0 100644 --- a/docs/upgrade-to-v4.mdx +++ b/docs/upgrade-to-v4.mdx @@ -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`. From 62b6485f8832d1c1a204771667694a19262b055c Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Wed, 14 May 2025 12:05:02 +0100 Subject: [PATCH 4/5] rename node-22 runtime to node-test and only use node 21 for now --- packages/cli-v3/src/deploy/buildImage.ts | 12 ++++++++---- packages/core/src/v3/build/runtime.ts | 6 +++--- packages/core/src/v3/config.ts | 2 ++ packages/core/src/v3/schemas/build.ts | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/cli-v3/src/deploy/buildImage.ts b/packages/cli-v3/src/deploy/buildImage.ts index bf2b937fb1..ace44382ff 100644 --- a/packages/cli-v3/src/deploy/buildImage.ts +++ b/packages/cli-v3/src/deploy/buildImage.ts @@ -473,10 +473,14 @@ 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 = { - 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"]; @@ -484,7 +488,7 @@ const DEFAULT_PACKAGES = ["busybox", "ca-certificates", "dumb-init", "git", "ope export async function generateContainerfile(options: GenerateContainerfileOptions) { switch (options.runtime) { case "node": - case "node-22": { + case "node-test": { return await generateNodeContainerfile(options); } } diff --git a/packages/core/src/v3/build/runtime.ts b/packages/core/src/v3/build/runtime.ts index 28a3fabbe3..3305b48a3f 100644 --- a/packages/core/src/v3/build/runtime.ts +++ b/packages/core/src/v3/build/runtime.ts @@ -8,7 +8,7 @@ export const DEFAULT_RUNTIME = "node" satisfies BuildRuntime; export function binaryForRuntime(runtime: BuildRuntime): string { switch (runtime) { case "node": - case "node-22": + case "node-test": return "node"; default: throw new Error(`Unsupported runtime ${runtime}`); @@ -18,7 +18,7 @@ export function binaryForRuntime(runtime: BuildRuntime): string { export function execPathForRuntime(runtime: BuildRuntime): string { switch (runtime) { case "node": - case "node-22": + case "node-test": return process.execPath; default: throw new Error(`Unsupported runtime ${runtime}`); @@ -37,7 +37,7 @@ export function execOptionsForRuntime( ): string { switch (runtime) { case "node": - case "node-22": { + case "node-test": { const importEntryPoint = options.loaderEntryPoint ? `--import=${pathToFileURL(options.loaderEntryPoint).href}` : undefined; diff --git a/packages/core/src/v3/config.ts b/packages/core/src/v3/config.ts index a98b8f03d5..511a05590f 100644 --- a/packages/core/src/v3/config.ts +++ b/packages/core/src/v3/config.ts @@ -21,6 +21,8 @@ export type CompatibilityFlagFeatures = { export type TriggerConfig = { /** + * The runtime to use for your trigger.dev tasks. + * * @default "node" */ runtime?: BuildRuntime; diff --git a/packages/core/src/v3/schemas/build.ts b/packages/core/src/v3/schemas/build.ts index 2dda9a6be8..8053f5824f 100644 --- a/packages/core/src/v3/schemas/build.ts +++ b/packages/core/src/v3/schemas/build.ts @@ -13,7 +13,7 @@ export const BuildTarget = z.enum(["dev", "deploy", "unmanaged"]); export type BuildTarget = z.infer; -export const BuildRuntime = z.enum(["node", "node-22"]); +export const BuildRuntime = z.enum(["node", "node-test"]); export type BuildRuntime = z.infer; From 988a3989ef4e0b8280f8c762aca5f1bf6069b7cd Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Wed, 14 May 2025 12:08:00 +0100 Subject: [PATCH 5/5] update changeset --- .changeset/mighty-dryers-warn.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/mighty-dryers-warn.md b/.changeset/mighty-dryers-warn.md index cc012d2d07..f06c8deb56 100644 --- a/.changeset/mighty-dryers-warn.md +++ b/.changeset/mighty-dryers-warn.md @@ -4,4 +4,4 @@ "@trigger.dev/rsc": patch --- -Remove experimental Bun support +Remove experimental `bun` support. `node` is now the only supported runtime.