Skip to content

Commit

Permalink
process local extensions serially
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcphers committed Dec 17, 2024
1 parent 31e217d commit 162e57e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 12 deletions.
25 changes: 21 additions & 4 deletions build/lib/extensions.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 28 additions & 8 deletions build/lib/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,14 +427,34 @@ export function packageLocalExtensionsStream(forWeb: boolean, disableMangle: boo
.filter(({ name }) => builtInExtensions.every(b => b.name !== name))
.filter(({ manifestPath }) => (forWeb ? isWebExtension(require(manifestPath)) : true))
);
const localExtensionsStream = minifyExtensionResources(
es.merge(
...localExtensionsDescriptions.map(extension => {
return fromLocal(extension.path, forWeb, disableMangle)
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
})
)
);

// --- Start Positron ---

// Process the local extensions serially to avoid running out of file
// descriptors (EMFILE) when building.

const localExtensionsStream = es.through();
const queue = [...localExtensionsDescriptions];

function processNext() {
if (queue.length === 0) {
localExtensionsStream.end();
return;
}

const extension = queue.shift();
if (!extension) {
return;
}
const stream = fromLocal(extension.path, forWeb, disableMangle)
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`))
.pipe(es.through(undefined, processNext));

stream.pipe(localExtensionsStream, { end: false });
}

processNext();
// --- End Positron ---

let result: Stream;
if (forWeb) {
Expand Down

0 comments on commit 162e57e

Please sign in to comment.