fix(workers): isolate compiled host selectors
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
import { stripWindowsExtendedLengthPathPrefix } from "./path";
|
||||
|
||||
/** Prefix reserved for argv selectors dispatched by the shared CLI worker host. */
|
||||
export const WORKER_HOST_SELECTOR_PREFIX = "__omp_worker_";
|
||||
|
||||
/** Whether an argv value selects a worker hosted by the shared CLI entrypoint. */
|
||||
export function isWorkerHostSelector(value: string | undefined): value is string {
|
||||
return value?.startsWith(WORKER_HOST_SELECTOR_PREFIX) ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Main-module path declared by self-dispatching CLI entrypoints — entries
|
||||
* whose top-level argv handling routes hidden `__omp_*` worker selectors.
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import { afterEach, beforeEach, describe, expect, it } from "bun:test";
|
||||
import { EventEmitter } from "node:events";
|
||||
import { consumeWorkerInbox, installWorkerInbox } from "../src/worker-host";
|
||||
import {
|
||||
consumeWorkerInbox,
|
||||
installWorkerInbox,
|
||||
isWorkerHostSelector,
|
||||
WORKER_HOST_SELECTOR_PREFIX,
|
||||
} from "../src/worker-host";
|
||||
|
||||
/**
|
||||
* Regression for JS/tab eval workers always stalling until the init timeout.
|
||||
@@ -14,6 +19,16 @@ import { consumeWorkerInbox, installWorkerInbox } from "../src/worker-host";
|
||||
* buffers until the worker module `bind`s the real handler; these tests pin that
|
||||
* buffer-replay contract.
|
||||
*/
|
||||
describe("worker-host selectors", () => {
|
||||
it("recognizes the shared selector namespace without claiming ordinary CLI arguments", () => {
|
||||
expect(WORKER_HOST_SELECTOR_PREFIX).toBe("__omp_worker_");
|
||||
expect(isWorkerHostSelector("__omp_worker_stats_sync")).toBeTrue();
|
||||
expect(isWorkerHostSelector("__omp_worker_computer")).toBeTrue();
|
||||
expect(isWorkerHostSelector("--version")).toBeFalse();
|
||||
expect(isWorkerHostSelector(undefined)).toBeFalse();
|
||||
});
|
||||
});
|
||||
|
||||
describe("worker-host inbox", () => {
|
||||
// State is a module-global stash (one worker per process); drain it around
|
||||
// each test so nothing leaks into the next.
|
||||
|
||||
Reference in New Issue
Block a user