Skip to content

Commit

Permalink
fix tinypool windows bug?
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Jan 27, 2025
1 parent d55360d commit 0a34905
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 3 additions & 5 deletions packages/docusaurus/src/ssg/ssgExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ import type {Props, RouterType} from '@docusaurus/types';
import type {SiteCollectedData} from '../common';
import type {SSGParams} from './ssgParams';
import type {SSGGlobalResult} from './ssgGlobalResult';

// @ts-expect-error: with resolution
import type {ExecuteSSGWorkerThreadTask} from './ssgWorkerThread.mts';
import type {ExecuteSSGWorkerThreadTask} from './ssgWorkerThread';

type SSGExecutor = {
run: () => Promise<SSGGlobalResult>;
Expand Down Expand Up @@ -118,12 +116,12 @@ const createPooledSSGExecutor: CreateSSGExecutor = async ({
const Tinypool = await import('tinypool').then((m) => m.default);

const workerURL = pathToFileURL(
path.resolve(__dirname, 'ssgWorkerThread.mjs'),
path.resolve(__dirname, 'ssgWorkerThread.js'),
);
console.log('workerURL', workerURL);

return new Tinypool({
filename: workerURL.href,
filename: workerURL.pathname,
minThreads: numberOfThreads,
maxThreads: numberOfThreads,
concurrentTasksPerWorker: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (!params) {
throw new Error(`SSG Worker Thread workerData params missing`);
}

const WorkerLogPrefix = `SSG Worker ${logger.default.name(workerId)}`;
const WorkerLogPrefix = `SSG Worker ${logger.name(workerId)}`;

// We only load once the SSG rendered (expensive), NOT once per worker task
// TODO check potential memory leak?
Expand All @@ -46,9 +46,9 @@ export default async function executeSSGWorkerThreadTask(
const appRenderer = await appRendererPromise;

const ssgResults = await PerfLogger.async(
`${WorkerLogPrefix} - Task ${logger.default.name(
`${WorkerLogPrefix} - Task ${logger.name(
task.id,
)} - Rendering ${logger.default.cyan(task.pathnames.length)} pathnames`,
)} - Rendering ${logger.cyan(task.pathnames.length)} pathnames`,
() => appRenderer.renderPathnames(task.pathnames),
);

Expand Down

0 comments on commit 0a34905

Please sign in to comment.