Skip to content
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

[TRI-2795] Add bun support #1191

Open
matt-aitken opened this issue Jun 28, 2024 · 4 comments
Open

[TRI-2795] Add bun support #1191

matt-aitken opened this issue Jun 28, 2024 · 4 comments
Labels
v3 Only impacts version 3 projects

Comments

@matt-aitken
Copy link
Member

matt-aitken commented Jun 28, 2024

Currently if you use bun it actually just uses npm (we detect a bun lock file and fallback to using npm).

Adding official bun support would mean you could call postinstall scripts using bun and do other bun specific things. As bun is a package manager and a runtime there are various levels of support we could go to.

TRI-2795

@matt-aitken matt-aitken added the v3 Only impacts version 3 projects label Jun 28, 2024
@matt-aitken matt-aitken changed the title Add bun support [TRI-2795] Add bun support Jun 28, 2024
@cellulosa
Copy link

cellulosa commented Aug 5, 2024

Just in case anybody else needs this, I was hitting version mismatch errors after updating the sdk package (with bun update).
What I had to do was to delete the bun cache (on MacOS is at /private/tmp/bunx-501-trigger.dev@beta) and everything started working again.

Otherwise with bun everything works pretty seamlessly, here's what I did:

  1. Install trigger.dev with bun add @trigger.dev/[email protected]
  2. Create a project manually on https://cloud.trigger.dev
  3. Create manually the trigger.config.ts on the project root folder:
import type { TriggerConfig } from '@trigger.dev/sdk/v3';
 
export const config: TriggerConfig = {
 project: 'project id as found under project settings on https://cloud.trigger.dev',
 logLevel: 'log',
 retries: {
  enabledInDev: true,
  default: {
   maxAttempts: 3,
   minTimeoutInMs: 1000,
   maxTimeoutInMs: 10000,
   factor: 2,
   randomize: true
  }
 },
 triggerDirectories: ['./trigger'],
};
  1. And obviously tasks e.g. /trigger/example.ts:
import { logger, task, wait } from '@trigger.dev/sdk/v3';

export const helloWorldTask = task({
	id: 'hello-world',
	run: async (payload: any, { ctx }) => {
		logger.log('Hello, world!', { payload, ctx });

		await wait.for({ seconds: 5 });

		return {
			message: 'Hello, world!'
		};
	}
});

You can now run it with bunx trigger.dev@beta dev.

@CptJJ
Copy link

CptJJ commented Aug 11, 2024

@cellulosa What framework are you using here?

bunx trigger.dev@beta dev seems to have problems picking up the default nextjs install which creates a src/jobs folder, despite correctly changing the trigger directory in the config.

It seems the default nextjs install doesn't even make a trigger.config.ts file but when you bunx it looks for it. Maybe I'm missing something here?

@cellulosa
Copy link

You' re right I should have said... I'm working with sveltekit

@Nnadivictory25
Copy link

This does not work for me either
Now I'm getting "cannot resolve bun"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v3 Only impacts version 3 projects
Projects
None yet
Development

No branches or pull requests

4 participants