what if I bundle my project as an executable, how would that work with sandboxed processors? #35
Replies: 1 comment 1 reply
-
|
Great question — this is a real limitation right now. The problem
The path resolution logic (in const fullPath = processorPath.startsWith('/')
? processorPath
: `${process.cwd()}/${processorPath}`;So it always expects a real file at that path. Current workaroundsOption 1: Ship processor files alongside the binary (recommended)Keep your processor files as separate # Build the main app
bun build --compile src/main.ts --outfile dist/myapp
# Copy processor files alongside
cp src/processors/*.ts dist/processors/Then reference them with an absolute or relative path: const worker = new SandboxedWorker('queue', {
processor: './processors/myProcessor.ts', // exists on disk next to binary
});This is the simplest approach and works reliably. Option 2: Use the regular Worker insteadIf you want a single binary with no extra files, switch to the regular import { Worker } from 'bunqueue/client';
const worker = new Worker('queue', async (job) => {
// Your processing logic directly here
return await processJob(job.data);
}, { embedded: true, concurrency: 3 });The trade-off: regular Option 3: Use TCP mode with a separate worker processRun bunqueue as a server, and have a separate (non-compiled) worker process: # Terminal 1: your compiled app (pushes jobs)
./dist/myapp
# Terminal 2: worker process (separate, with source files)
bun src/worker.tsThis gives you full isolation without needing the processor file in the binary. Future improvementI'll look into supporting an inline processor function for // Hypothetical future API
const worker = new SandboxedWorker('queue', {
processor: async (job) => { /* inline */ }, // no file needed
maxMemory: 512,
});For now, option 1 (ship processor files alongside the binary) is the recommended path. Let me know if you need help setting it up! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Because then that file would not exist anymore
Beta Was this translation helpful? Give feedback.
All reactions