Skip to content

Commit 207820e

Browse files
adrians5jclaude
andcommitted
docs(self-hosted): note worker-file deploy limitation (#5429) + extract currentDir
Extract currentDir in WorkerTaskService for readability, and add pointers to issue #5429 (standalone server build must externalize the worker-file packages) next to both runtime sidecar-file loaders (background-tasks worker, scheduler bree pollWorker). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 54bfbbc commit 207820e

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

packages/api-scheduler-server/src/BreeSchedulerService.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import {
99
} from "@webiny/api-scheduler/shared/abstractions.js";
1010
import type { Logger } from "@webiny/api-core/features/logger/abstractions.js";
1111

12+
// bree loads this worker file at runtime, resolved relative to this module's own dist. Works in
13+
// `webiny watch`; shipping a standalone server build requires externalizing this package so the
14+
// worker travels in node_modules — tracked in https://github.com/webiny/webiny-js/issues/5429.
1215
const jobsDir = join(dirname(fileURLToPath(import.meta.url)), "jobs");
1316
const workerPath = join(jobsDir, "pollWorker.js");
1417

packages/background-tasks-server/src/service/WorkerTaskService.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ class WorkerServiceImpl implements TaskService.Interface {
4646
// ("/static/assets/workerEntry.<hash>.js") that `new Worker()` can't load as a filesystem
4747
// path. `path.join` off `import.meta.url` (which resolves to this file inside dist) is left
4848
// untouched by the bundler and points at the real, node-resolvable dist worker.
49-
const workerPath = path.join(
50-
path.dirname(fileURLToPath(import.meta.url)),
51-
"..",
52-
"worker",
53-
"workerEntry.js"
54-
);
49+
//
50+
// NOTE: this works in `webiny watch` (dist resolves via the monorepo). Shipping a standalone
51+
// server build requires this package to be externalized so the worker file travels in
52+
// node_modules — tracked in https://github.com/webiny/webiny-js/issues/5429.
53+
const currentDir = path.dirname(fileURLToPath(import.meta.url));
54+
const workerPath = path.join(currentDir, "..", "worker", "workerEntry.js");
5555
const worker = new Worker(workerPath);
5656

5757
const handle: WorkerHandle = {

0 commit comments

Comments
 (0)