Skip to content

Invalid job class with Bun #154

@lauritzsh

Description

@lauritzsh

I saw #72 and it seems Piscina is working now with Bun oven-sh/bun#19924 (comment) so I wanted to give it a shot, but I'm running into another issue which might be related or not.

I copied the Hello, World example

import { Job } from "sidequest";

export class HelloJob extends Job {
	run(name: string) {
		const msg = `hello ${name}`;
		console.log(msg);
		return msg;
	}
}

I have a simple setup for running it

import { Sidequest } from "sidequest";
import { HelloJob } from "@/jobs/HelloJob";

Sidequest.start({
	backend: {
		driver: "@sidequest/postgres-backend",
		config: "postgresql://postgres:postgres@localhost:6432/postgres",
	},
});

Sidequest.build(HelloJob).enqueue("Hello");

but I just get

❯ bun src/scripts/test.ts
[info] [2026-01-11 11:24:44] [Sidequest] [Engine] : Starting Sidequest using backend @sidequest/postgres-backend
[info] [2026-01-11 11:24:44] [Sidequest] [Dashboard] : Server running on http://localhost:8678
[info] [2026-01-11 11:24:44] [Sidequest] [Worker] : Starting worker with provided configuration...
[info] [2026-01-11 11:24:44] [Sidequest] [Core] : Running job #7 - HelloJob
[error] [2026-01-11 11:24:44] [Sidequest] [Runner] : Invalid job class: HelloJob
[error] [2026-01-11 11:24:44] [Sidequest] [Core] : Invalid job class: HelloJob
{
  name: 'Error',
  originalLine: 42,
  originalColumn: 81,
  line: 61,
  column: 43,
  sourceURL: '/Users/lauritz/Developer/fenzhong/node_modules/@sidequest/engine/dist/shared-runner/runner.js',
  Symbol(level): 'error'
}
Error: Invalid job class: HelloJob
    at run (/Users/lauritz/Developer/fenzhong/node_modules/@sidequest/engine/dist/shared-runner/runner.js:61:43)
    at async onMessage (/Users/lauritz/Developer/fenzhong/node_modules/piscina/dist/worker.js:180:28)
    at processTicksAndRejections (native:7:39)

If I run with tsx it's all fine

❯ npx tsx src/scripts/test.ts
[info] [2026-01-11 11:26:05] [Sidequest] [Engine] : Starting Sidequest using backend @sidequest/postgres-backend
[info] [2026-01-11 11:26:05] [Sidequest] [Dashboard] : Server running on http://localhost:8678
[info] [2026-01-11 11:26:06] [Sidequest] [Worker] : Starting worker with provided configuration...
[info] [2026-01-11 11:26:06] [Sidequest] [Core] : Running job #9 - HelloJob
hello Hello
[info] [2026-01-11 11:26:06] [Sidequest] [Core] : Job #9 - HelloJob has completed

I'm creating a new issue as the other was closed, and this time it's a different error message. Feel free to close if it's still an issue related to Piscina.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions