#Cannot find module '.../.trigger/tmp/build-jBBU2y/lib/worker.js'

1 messages · Page 1 of 1 (latest)

deep frigate
#

Hi, trying out Trigger.dev and got it working with 2 tasks.

Now when I go and add a 3rd, I keep getting this:

Error: Build failed
Uncaught exception: Cannot find module '/apps/ticketnotifier/.trigger/tmp/build-jBBU2y/lib/worker.js'

UncaughtExceptionError: Cannot find module '/apps/ticketnotifier/.trigger/tmp/build-jBBU2y/lib/worker.js'
    at ChildProcess.<anonymous> (trigger.dev/dist/esm/indexing/indexWorkerManifest.js:56:28)
    at ChildProcess.emit (node:events:518:28)
    at emit (node:internal/child_process:950:14)
    at processTicksAndRejections (node:internal/process/task_queues:91:21)

I'm on Ubuntu 24.04, node.js 22.11.0. I've also tried on macOS, and got the same error (just with different paths in the stacktrace)

It seems no matter the content of my 3rd tasks, it fails randomly (sometimes just changing the file name makes it work)

I've tried deleting stuff line by line to find the culprit import but it's very inconsistent. If I delete everything from the file (empty), it still fails with the same error. I've tried clearing my pnpm dlx cache manually, but no luck.

Nothing unusual running with --log-level verbose -- A successful run prints

worker manifest indexed {
  path: '/mnt/ssd-nvme-4tb/WebstormProjects/acme-corp/apps/ticketnotifier/.trigger/tmp/build-Hfb7f7'
}

While a failed one does not.

This seems similar to this other issue: https://discord.com/channels/1066956501299777596/1290983187232591872

tidal fable
#

If you delete your .trigger folder, which is the cache, and then re-run the result is the same?

The fix for the issue referenced in that other post ended up being this:

Seems to be because I was importing a helper function from a route handler, if i copy the helper to file thats using it that is being imported in the task the worker builds fine

deep frigate
#

Yup, I get the same issue. Sometimes I find an import that if I remove it starts working and if I re-add it breaks. My last one was @upstash/qstash

#

I get that it's a hard-to-debug issue without a repro so I'll see if I can make one

No need to look into it further -- Mostly wanted to flag it so if you're searching for DX improvements to do in the future there might be a chance to do better error handling / have a better error message here with the root cause

tidal fable
#

Yeah I'd love to figure this out so we can either hopefully prevent it from happening. Or failing that have an error messge that has a fix in it.

#

@viral escarp you might know what this is

viral escarp
#

Nope I have no idea, have seen this "Cannot find module .../lib/worker.js" a couple times recently, but I'm not sure what is trying to load that (it's not us, we don't load any kind of "lib/worker.js" module

tidal fable
#

Are you creating a worker using the Node.js worker_threads module?

deep frigate
#

Nope

#

But good news

#

After some more debugging I've nailed it down to adding:

build: {
    external: ["@axiomhq/pino", "pino", "pino-pretty"],
  },

to my trigger.config.ts. It now works!

#

(I'm using turborepo, and this pino was like 4 dependencies deep in internal packages)