workerMain.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. "use strict";
  2. var __defProp = Object.defineProperty;
  3. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  4. var __getOwnPropNames = Object.getOwnPropertyNames;
  5. var __hasOwnProp = Object.prototype.hasOwnProperty;
  6. var __export = (target, all) => {
  7. for (var name in all)
  8. __defProp(target, name, { get: all[name], enumerable: true });
  9. };
  10. var __copyProps = (to, from, except, desc) => {
  11. if (from && typeof from === "object" || typeof from === "function") {
  12. for (let key of __getOwnPropNames(from))
  13. if (!__hasOwnProp.call(to, key) && key !== except)
  14. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  15. }
  16. return to;
  17. };
  18. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  19. var workerMain_exports = {};
  20. __export(workerMain_exports, {
  21. WorkerMain: () => WorkerMain,
  22. create: () => create
  23. });
  24. module.exports = __toCommonJS(workerMain_exports);
  25. var import_utils = require("playwright-core/lib/utils");
  26. var import_utils2 = require("playwright-core/lib/utils");
  27. var import_configLoader = require("../common/configLoader");
  28. var import_globals = require("../common/globals");
  29. var import_ipc = require("../common/ipc");
  30. var import_util = require("../util");
  31. var import_fixtureRunner = require("./fixtureRunner");
  32. var import_testInfo = require("./testInfo");
  33. var import_util2 = require("./util");
  34. var import_fixtures = require("../common/fixtures");
  35. var import_poolBuilder = require("../common/poolBuilder");
  36. var import_process = require("../common/process");
  37. var import_suiteUtils = require("../common/suiteUtils");
  38. var import_testLoader = require("../common/testLoader");
  39. class WorkerMain extends import_process.ProcessRunner {
  40. constructor(params) {
  41. super();
  42. // Accumulated fatal errors that cannot be attributed to a test.
  43. this._fatalErrors = [];
  44. // The stage of the full cleanup. Once "finished", we can safely stop running anything.
  45. this._didRunFullCleanup = false;
  46. // Whether the worker was requested to stop.
  47. this._isStopped = false;
  48. // This promise resolves once the single "run test group" call finishes.
  49. this._runFinished = new import_utils.ManualPromise();
  50. this._currentTest = null;
  51. this._lastRunningTests = [];
  52. this._totalRunningTests = 0;
  53. // Suites that had their beforeAll hooks, but not afterAll hooks executed.
  54. // These suites still need afterAll hooks to be executed for the proper cleanup.
  55. // Contains dynamic annotations originated by modifiers with a callback, e.g. `test.skip(() => true)`.
  56. this._activeSuites = /* @__PURE__ */ new Map();
  57. process.env.TEST_WORKER_INDEX = String(params.workerIndex);
  58. process.env.TEST_PARALLEL_INDEX = String(params.parallelIndex);
  59. (0, import_globals.setIsWorkerProcess)();
  60. this._params = params;
  61. this._fixtureRunner = new import_fixtureRunner.FixtureRunner();
  62. this._runFinished.resolve();
  63. process.on("unhandledRejection", (reason) => this.unhandledError(reason));
  64. process.on("uncaughtException", (error) => this.unhandledError(error));
  65. process.stdout.write = (chunk, cb) => {
  66. this.dispatchEvent("stdOut", (0, import_ipc.stdioChunkToParams)(chunk));
  67. this._currentTest?._tracing.appendStdioToTrace("stdout", chunk);
  68. if (typeof cb === "function")
  69. process.nextTick(cb);
  70. return true;
  71. };
  72. if (!process.env.PW_RUNNER_DEBUG) {
  73. process.stderr.write = (chunk, cb) => {
  74. this.dispatchEvent("stdErr", (0, import_ipc.stdioChunkToParams)(chunk));
  75. this._currentTest?._tracing.appendStdioToTrace("stderr", chunk);
  76. if (typeof cb === "function")
  77. process.nextTick(cb);
  78. return true;
  79. };
  80. }
  81. }
  82. _stop() {
  83. if (!this._isStopped) {
  84. this._isStopped = true;
  85. this._currentTest?._interrupt();
  86. }
  87. return this._runFinished;
  88. }
  89. async gracefullyClose() {
  90. try {
  91. await this._stop();
  92. if (!this._config) {
  93. return;
  94. }
  95. const fakeTestInfo = new import_testInfo.TestInfoImpl(this._config, this._project, this._params, void 0, 0, () => {
  96. }, () => {
  97. }, () => {
  98. }, () => {
  99. });
  100. const runnable = { type: "teardown" };
  101. await fakeTestInfo._runWithTimeout(runnable, () => this._loadIfNeeded()).catch(() => {
  102. });
  103. await this._fixtureRunner.teardownScope("test", fakeTestInfo, runnable).catch(() => {
  104. });
  105. await this._fixtureRunner.teardownScope("worker", fakeTestInfo, runnable).catch(() => {
  106. });
  107. await fakeTestInfo._runWithTimeout(runnable, () => (0, import_utils.gracefullyCloseAll)()).catch(() => {
  108. });
  109. this._fatalErrors.push(...fakeTestInfo.errors);
  110. } catch (e) {
  111. this._fatalErrors.push((0, import_util2.testInfoError)(e));
  112. }
  113. if (this._fatalErrors.length) {
  114. this._appendProcessTeardownDiagnostics(this._fatalErrors[this._fatalErrors.length - 1]);
  115. const payload = { fatalErrors: this._fatalErrors };
  116. this.dispatchEvent("teardownErrors", payload);
  117. }
  118. }
  119. _appendProcessTeardownDiagnostics(error) {
  120. if (!this._lastRunningTests.length)
  121. return;
  122. const count = this._totalRunningTests === 1 ? "1 test" : `${this._totalRunningTests} tests`;
  123. let lastMessage = "";
  124. if (this._lastRunningTests.length < this._totalRunningTests)
  125. lastMessage = `, last ${this._lastRunningTests.length} tests were`;
  126. const message = [
  127. "",
  128. "",
  129. import_utils2.colors.red(`Failed worker ran ${count}${lastMessage}:`),
  130. ...this._lastRunningTests.map((test) => formatTestTitle(test, this._project.project.name))
  131. ].join("\n");
  132. if (error.message) {
  133. if (error.stack) {
  134. let index = error.stack.indexOf(error.message);
  135. if (index !== -1) {
  136. index += error.message.length;
  137. error.stack = error.stack.substring(0, index) + message + error.stack.substring(index);
  138. }
  139. }
  140. error.message += message;
  141. } else if (error.value) {
  142. error.value += message;
  143. }
  144. }
  145. unhandledError(error) {
  146. if (!this._currentTest) {
  147. if (!this._fatalErrors.length)
  148. this._fatalErrors.push((0, import_util2.testInfoError)(error));
  149. void this._stop();
  150. return;
  151. }
  152. if (!this._currentTest._hasUnhandledError) {
  153. this._currentTest._hasUnhandledError = true;
  154. this._currentTest._failWithError(error);
  155. }
  156. const isExpectError = error instanceof Error && !!error.matcherResult;
  157. const shouldContinueInThisWorker = this._currentTest.expectedStatus === "failed" && isExpectError;
  158. if (!shouldContinueInThisWorker)
  159. void this._stop();
  160. }
  161. async _loadIfNeeded() {
  162. if (this._config)
  163. return;
  164. const config = await (0, import_configLoader.deserializeConfig)(this._params.config);
  165. const project = config.projects.find((p) => p.id === this._params.projectId);
  166. if (!project)
  167. throw new Error(`Project "${this._params.projectId}" not found in the worker process. Make sure project name does not change.`);
  168. this._config = config;
  169. this._project = project;
  170. this._poolBuilder = import_poolBuilder.PoolBuilder.createForWorker(this._project);
  171. }
  172. async runTestGroup(runPayload) {
  173. this._runFinished = new import_utils.ManualPromise();
  174. const entries = new Map(runPayload.entries.map((e) => [e.testId, e]));
  175. let fatalUnknownTestIds;
  176. try {
  177. await this._loadIfNeeded();
  178. const fileSuite = await (0, import_testLoader.loadTestFile)(runPayload.file, this._config.config.rootDir);
  179. const suite = (0, import_suiteUtils.bindFileSuiteToProject)(this._project, fileSuite);
  180. if (this._params.repeatEachIndex)
  181. (0, import_suiteUtils.applyRepeatEachIndex)(this._project, suite, this._params.repeatEachIndex);
  182. const hasEntries = (0, import_suiteUtils.filterTestsRemoveEmptySuites)(suite, (test) => entries.has(test.id));
  183. if (hasEntries) {
  184. this._poolBuilder.buildPools(suite);
  185. this._activeSuites = /* @__PURE__ */ new Map();
  186. this._didRunFullCleanup = false;
  187. const tests = suite.allTests();
  188. for (let i = 0; i < tests.length; i++) {
  189. if (this._isStopped && this._didRunFullCleanup)
  190. break;
  191. const entry = entries.get(tests[i].id);
  192. entries.delete(tests[i].id);
  193. (0, import_util.debugTest)(`test started "${tests[i].title}"`);
  194. await this._runTest(tests[i], entry.retry, tests[i + 1]);
  195. (0, import_util.debugTest)(`test finished "${tests[i].title}"`);
  196. }
  197. } else {
  198. fatalUnknownTestIds = runPayload.entries.map((e) => e.testId);
  199. void this._stop();
  200. }
  201. } catch (e) {
  202. this._fatalErrors.push((0, import_util2.testInfoError)(e));
  203. void this._stop();
  204. } finally {
  205. const donePayload = {
  206. fatalErrors: this._fatalErrors,
  207. skipTestsDueToSetupFailure: [],
  208. fatalUnknownTestIds
  209. };
  210. for (const test of this._skipRemainingTestsInSuite?.allTests() || []) {
  211. if (entries.has(test.id))
  212. donePayload.skipTestsDueToSetupFailure.push(test.id);
  213. }
  214. this.dispatchEvent("done", donePayload);
  215. this._fatalErrors = [];
  216. this._skipRemainingTestsInSuite = void 0;
  217. this._runFinished.resolve();
  218. }
  219. }
  220. resumeAfterStepError(params) {
  221. this._currentTest?.resumeAfterStepError(params);
  222. }
  223. async _runTest(test, retry, nextTest) {
  224. const testInfo = new import_testInfo.TestInfoImpl(
  225. this._config,
  226. this._project,
  227. this._params,
  228. test,
  229. retry,
  230. (stepBeginPayload) => this.dispatchEvent("stepBegin", stepBeginPayload),
  231. (stepRecoverFromErrorPayload) => this.dispatchEvent("stepRecoverFromError", stepRecoverFromErrorPayload),
  232. (stepEndPayload) => this.dispatchEvent("stepEnd", stepEndPayload),
  233. (attachment) => this.dispatchEvent("attach", attachment)
  234. );
  235. const processAnnotation = (annotation) => {
  236. testInfo.annotations.push(annotation);
  237. switch (annotation.type) {
  238. case "fixme":
  239. case "skip":
  240. testInfo.expectedStatus = "skipped";
  241. break;
  242. case "fail":
  243. if (testInfo.expectedStatus !== "skipped")
  244. testInfo.expectedStatus = "failed";
  245. break;
  246. case "slow":
  247. testInfo._timeoutManager.slow();
  248. break;
  249. }
  250. };
  251. if (!this._isStopped)
  252. this._fixtureRunner.setPool(test._pool);
  253. const suites = getSuites(test);
  254. const reversedSuites = suites.slice().reverse();
  255. const nextSuites = new Set(getSuites(nextTest));
  256. testInfo._timeoutManager.setTimeout(test.timeout);
  257. for (const annotation of test.annotations)
  258. processAnnotation(annotation);
  259. for (const suite of suites) {
  260. const extraAnnotations = this._activeSuites.get(suite) || [];
  261. for (const annotation of extraAnnotations)
  262. processAnnotation(annotation);
  263. }
  264. this._currentTest = testInfo;
  265. (0, import_globals.setCurrentTestInfo)(testInfo);
  266. this.dispatchEvent("testBegin", buildTestBeginPayload(testInfo));
  267. const isSkipped = testInfo.expectedStatus === "skipped";
  268. const hasAfterAllToRunBeforeNextTest = reversedSuites.some((suite) => {
  269. return this._activeSuites.has(suite) && !nextSuites.has(suite) && suite._hooks.some((hook) => hook.type === "afterAll");
  270. });
  271. if (isSkipped && nextTest && !hasAfterAllToRunBeforeNextTest) {
  272. testInfo.status = "skipped";
  273. this.dispatchEvent("testEnd", buildTestEndPayload(testInfo));
  274. return;
  275. }
  276. this._totalRunningTests++;
  277. this._lastRunningTests.push(test);
  278. if (this._lastRunningTests.length > 10)
  279. this._lastRunningTests.shift();
  280. let shouldRunAfterEachHooks = false;
  281. testInfo._allowSkips = true;
  282. await (async () => {
  283. await testInfo._runWithTimeout({ type: "test" }, async () => {
  284. const traceFixtureRegistration = test._pool.resolve("trace");
  285. if (!traceFixtureRegistration)
  286. return;
  287. if (typeof traceFixtureRegistration.fn === "function")
  288. throw new Error(`"trace" option cannot be a function`);
  289. await testInfo._tracing.startIfNeeded(traceFixtureRegistration.fn);
  290. });
  291. if (this._isStopped || isSkipped) {
  292. testInfo.status = "skipped";
  293. return;
  294. }
  295. await (0, import_utils.removeFolders)([testInfo.outputDir]);
  296. let testFunctionParams = null;
  297. await testInfo._runAsStep({ title: "Before Hooks", category: "hook" }, async () => {
  298. for (const suite of suites)
  299. await this._runBeforeAllHooksForSuite(suite, testInfo);
  300. shouldRunAfterEachHooks = true;
  301. await this._runEachHooksForSuites(suites, "beforeEach", testInfo);
  302. testFunctionParams = await this._fixtureRunner.resolveParametersForFunction(test.fn, testInfo, "test", { type: "test" });
  303. });
  304. if (testFunctionParams === null) {
  305. return;
  306. }
  307. await testInfo._runWithTimeout({ type: "test" }, async () => {
  308. const fn = test.fn;
  309. await fn(testFunctionParams, testInfo);
  310. });
  311. })().catch(() => {
  312. });
  313. testInfo.duration = testInfo._timeoutManager.defaultSlot().elapsed | 0;
  314. testInfo._allowSkips = true;
  315. const afterHooksTimeout = calculateMaxTimeout(this._project.project.timeout, testInfo.timeout);
  316. const afterHooksSlot = { timeout: afterHooksTimeout, elapsed: 0 };
  317. await testInfo._runAsStep({ title: "After Hooks", category: "hook" }, async () => {
  318. let firstAfterHooksError;
  319. try {
  320. await testInfo._runWithTimeout({ type: "test", slot: afterHooksSlot }, async () => testInfo._onDidFinishTestFunction?.());
  321. } catch (error) {
  322. firstAfterHooksError = firstAfterHooksError ?? error;
  323. }
  324. try {
  325. if (shouldRunAfterEachHooks)
  326. await this._runEachHooksForSuites(reversedSuites, "afterEach", testInfo, afterHooksSlot);
  327. } catch (error) {
  328. firstAfterHooksError = firstAfterHooksError ?? error;
  329. }
  330. testInfo._tracing.didFinishTestFunctionAndAfterEachHooks();
  331. try {
  332. await this._fixtureRunner.teardownScope("test", testInfo, { type: "test", slot: afterHooksSlot });
  333. } catch (error) {
  334. firstAfterHooksError = firstAfterHooksError ?? error;
  335. }
  336. for (const suite of reversedSuites) {
  337. if (!nextSuites.has(suite) || testInfo._isFailure()) {
  338. try {
  339. await this._runAfterAllHooksForSuite(suite, testInfo);
  340. } catch (error) {
  341. firstAfterHooksError = firstAfterHooksError ?? error;
  342. }
  343. }
  344. }
  345. if (firstAfterHooksError)
  346. throw firstAfterHooksError;
  347. }).catch(() => {
  348. });
  349. if (testInfo._isFailure())
  350. this._isStopped = true;
  351. if (this._isStopped) {
  352. this._didRunFullCleanup = true;
  353. await testInfo._runAsStep({ title: "Worker Cleanup", category: "hook" }, async () => {
  354. let firstWorkerCleanupError;
  355. const teardownSlot = { timeout: this._project.project.timeout, elapsed: 0 };
  356. try {
  357. await this._fixtureRunner.teardownScope("test", testInfo, { type: "test", slot: teardownSlot });
  358. } catch (error) {
  359. firstWorkerCleanupError = firstWorkerCleanupError ?? error;
  360. }
  361. for (const suite of reversedSuites) {
  362. try {
  363. await this._runAfterAllHooksForSuite(suite, testInfo);
  364. } catch (error) {
  365. firstWorkerCleanupError = firstWorkerCleanupError ?? error;
  366. }
  367. }
  368. try {
  369. await this._fixtureRunner.teardownScope("worker", testInfo, { type: "teardown", slot: teardownSlot });
  370. } catch (error) {
  371. firstWorkerCleanupError = firstWorkerCleanupError ?? error;
  372. }
  373. if (firstWorkerCleanupError)
  374. throw firstWorkerCleanupError;
  375. }).catch(() => {
  376. });
  377. }
  378. const tracingSlot = { timeout: this._project.project.timeout, elapsed: 0 };
  379. await testInfo._runWithTimeout({ type: "test", slot: tracingSlot }, async () => {
  380. await testInfo._tracing.stopIfNeeded();
  381. }).catch(() => {
  382. });
  383. testInfo.duration = testInfo._timeoutManager.defaultSlot().elapsed + afterHooksSlot.elapsed | 0;
  384. this._currentTest = null;
  385. (0, import_globals.setCurrentTestInfo)(null);
  386. this.dispatchEvent("testEnd", buildTestEndPayload(testInfo));
  387. const preserveOutput = this._config.config.preserveOutput === "always" || this._config.config.preserveOutput === "failures-only" && testInfo._isFailure();
  388. if (!preserveOutput)
  389. await (0, import_utils.removeFolders)([testInfo.outputDir]);
  390. }
  391. _collectHooksAndModifiers(suite, type, testInfo) {
  392. const runnables = [];
  393. for (const modifier of suite._modifiers) {
  394. const modifierType = this._fixtureRunner.dependsOnWorkerFixturesOnly(modifier.fn, modifier.location) ? "beforeAll" : "beforeEach";
  395. if (modifierType !== type)
  396. continue;
  397. const fn = async (fixtures) => {
  398. const result = await modifier.fn(fixtures);
  399. testInfo._modifier(modifier.type, modifier.location, [!!result, modifier.description]);
  400. };
  401. (0, import_fixtures.inheritFixtureNames)(modifier.fn, fn);
  402. runnables.push({
  403. title: `${modifier.type} modifier`,
  404. location: modifier.location,
  405. type: modifier.type,
  406. fn
  407. });
  408. }
  409. runnables.push(...suite._hooks.filter((hook) => hook.type === type));
  410. return runnables;
  411. }
  412. async _runBeforeAllHooksForSuite(suite, testInfo) {
  413. if (this._activeSuites.has(suite))
  414. return;
  415. const extraAnnotations = [];
  416. this._activeSuites.set(suite, extraAnnotations);
  417. await this._runAllHooksForSuite(suite, testInfo, "beforeAll", extraAnnotations);
  418. }
  419. async _runAllHooksForSuite(suite, testInfo, type, extraAnnotations) {
  420. let firstError;
  421. for (const hook of this._collectHooksAndModifiers(suite, type, testInfo)) {
  422. try {
  423. await testInfo._runAsStep({ title: hook.title, category: "hook", location: hook.location }, async () => {
  424. const timeSlot = { timeout: this._project.project.timeout, elapsed: 0 };
  425. const runnable = { type: hook.type, slot: timeSlot, location: hook.location };
  426. const existingAnnotations = new Set(testInfo.annotations);
  427. try {
  428. await this._fixtureRunner.resolveParametersAndRunFunction(hook.fn, testInfo, "all-hooks-only", runnable);
  429. } finally {
  430. if (extraAnnotations) {
  431. const newAnnotations = testInfo.annotations.filter((a) => !existingAnnotations.has(a));
  432. extraAnnotations.push(...newAnnotations);
  433. }
  434. await this._fixtureRunner.teardownScope("test", testInfo, runnable);
  435. }
  436. });
  437. } catch (error) {
  438. firstError = firstError ?? error;
  439. if (type === "beforeAll" && error instanceof import_testInfo.TestSkipError)
  440. break;
  441. if (type === "beforeAll" && !this._skipRemainingTestsInSuite) {
  442. this._skipRemainingTestsInSuite = suite;
  443. }
  444. }
  445. }
  446. if (firstError)
  447. throw firstError;
  448. }
  449. async _runAfterAllHooksForSuite(suite, testInfo) {
  450. if (!this._activeSuites.has(suite))
  451. return;
  452. this._activeSuites.delete(suite);
  453. await this._runAllHooksForSuite(suite, testInfo, "afterAll");
  454. }
  455. async _runEachHooksForSuites(suites, type, testInfo, slot) {
  456. let firstError;
  457. const hooks = suites.map((suite) => this._collectHooksAndModifiers(suite, type, testInfo)).flat();
  458. for (const hook of hooks) {
  459. const runnable = { type: hook.type, location: hook.location, slot };
  460. if (testInfo._timeoutManager.isTimeExhaustedFor(runnable)) {
  461. continue;
  462. }
  463. try {
  464. await testInfo._runAsStep({ title: hook.title, category: "hook", location: hook.location }, async () => {
  465. await this._fixtureRunner.resolveParametersAndRunFunction(hook.fn, testInfo, "test", runnable);
  466. });
  467. } catch (error) {
  468. firstError = firstError ?? error;
  469. if (error instanceof import_testInfo.TestSkipError)
  470. break;
  471. }
  472. }
  473. if (firstError)
  474. throw firstError;
  475. }
  476. }
  477. function buildTestBeginPayload(testInfo) {
  478. return {
  479. testId: testInfo.testId,
  480. startWallTime: testInfo._startWallTime
  481. };
  482. }
  483. function buildTestEndPayload(testInfo) {
  484. return {
  485. testId: testInfo.testId,
  486. duration: testInfo.duration,
  487. status: testInfo.status,
  488. errors: testInfo.errors,
  489. hasNonRetriableError: testInfo._hasNonRetriableError,
  490. expectedStatus: testInfo.expectedStatus,
  491. annotations: testInfo.annotations,
  492. timeout: testInfo.timeout
  493. };
  494. }
  495. function getSuites(test) {
  496. const suites = [];
  497. for (let suite = test?.parent; suite; suite = suite.parent)
  498. suites.push(suite);
  499. suites.reverse();
  500. return suites;
  501. }
  502. function formatTestTitle(test, projectName) {
  503. const [, ...titles] = test.titlePath();
  504. const location = `${(0, import_util.relativeFilePath)(test.location.file)}:${test.location.line}:${test.location.column}`;
  505. const projectTitle = projectName ? `[${projectName}] \u203A ` : "";
  506. return `${projectTitle}${location} \u203A ${titles.join(" \u203A ")}`;
  507. }
  508. function calculateMaxTimeout(t1, t2) {
  509. return !t1 || !t2 ? 0 : Math.max(t1, t2);
  510. }
  511. const create = (params) => new WorkerMain(params);
  512. // Annotate the CommonJS export names for ESM import in node:
  513. 0 && (module.exports = {
  514. WorkerMain,
  515. create
  516. });