Skip to content

Commit

Permalink
Merge pull request #1048 from ckeditor/ci/3882
Browse files Browse the repository at this point in the history
Fix (release-tools): Fixed path calculation in `executeInParallel()` util that prepares a path to a dynamically imported worker script. Previously, it did not work in Windows, because there is a specific requirement that absolute path must be valid `file://` protocol URL. Now, the worker script is always imported using `file://` protocol URL.
  • Loading branch information
psmyrek authored Nov 22, 2024
2 parents ba7b5e4 + 520dcb4 commit 3bbf3f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ export default async function executeInParallel( options ) {
return createWorker( {
signal: signal || defaultAbortController.signal,
onPackageDone,
workerData: { packages, callbackModule, taskOptions }
workerData: {
packages,
taskOptions,
// The callback module is dynamically imported inside worker script.
// To make it work in Windows, absolute path to a dynamically imported file must start with the "file:" protocol URL.
callbackModule: 'file://' + callbackModule
}
} );
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ describe( 'executeInParallel()', () => {
'utf-8'
);
expect( firstWorker.workerData ).toBeInstanceOf( Object );
expect( firstWorker.workerData ).toHaveProperty( 'callbackModule', '/home/ckeditor/uuid-4.mjs' );
expect( firstWorker.workerData ).toHaveProperty( 'callbackModule', 'file:///home/ckeditor/uuid-4.mjs' );
expect( firstWorker.workerData ).toHaveProperty( 'packages' );

expect( secondWorker.workerData ).toBeInstanceOf( Object );
expect( secondWorker.workerData ).toHaveProperty( 'callbackModule', '/home/ckeditor/uuid-4.mjs' );
expect( secondWorker.workerData ).toHaveProperty( 'callbackModule', 'file:///home/ckeditor/uuid-4.mjs' );
expect( secondWorker.workerData ).toHaveProperty( 'packages' );

// Workers did not emit an error.
Expand Down Expand Up @@ -231,11 +231,11 @@ describe( 'executeInParallel()', () => {
const [ firstWorker, secondWorker ] = stubs.WorkerMock.instances;

expect( firstWorker.workerData ).toBeInstanceOf( Object );
expect( firstWorker.workerData ).toHaveProperty( 'callbackModule', 'C:/Users/ckeditor/uuid-4.mjs' );
expect( firstWorker.workerData ).toHaveProperty( 'callbackModule', 'file://C:/Users/ckeditor/uuid-4.mjs' );
expect( firstWorker.workerData ).toHaveProperty( 'packages' );

expect( secondWorker.workerData ).toBeInstanceOf( Object );
expect( secondWorker.workerData ).toHaveProperty( 'callbackModule', 'C:/Users/ckeditor/uuid-4.mjs' );
expect( secondWorker.workerData ).toHaveProperty( 'callbackModule', 'file://C:/Users/ckeditor/uuid-4.mjs' );
expect( secondWorker.workerData ).toHaveProperty( 'packages' );

// Workers did not emit an error.
Expand Down

0 comments on commit 3bbf3f4

Please sign in to comment.