Skip to content

Commit

Permalink
fix(angular): add workaround to prevent process from exiting early wh…
Browse files Browse the repository at this point in the history
…en building

ISSUES CLOSED: nrwl#5729
  • Loading branch information
leosvelperez committed May 27, 2021
1 parent 42c0ed8 commit 64f3ed3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/tao/src/commands/ngcli-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable no-restricted-imports */
import {
json,
logging,
normalize,
Path,
Expand Down Expand Up @@ -49,8 +48,9 @@ export async function scheduleTarget(
workspaces.createWorkspaceHost(fsHost)
);

const registry = new json.schema.CoreSchemaRegistry();
const registry = new schema.CoreSchemaRegistry();
registry.addPostTransform(schema.transforms.addUndefinedDefaults);
registry.useXDeprecatedProvider((msg) => logger.warn(msg));
const architectHost = new WorkspaceNodeModulesArchitectHost(workspace, root);
const architect = new Architect(architectHost, registry);
const run = await architect.scheduleTarget(
Expand Down
33 changes: 22 additions & 11 deletions packages/tao/src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,30 @@ async function iteratorToProcessStatusCode(
): Promise<number> {
let success: boolean;

let prev: IteratorResult<{ success: boolean }>;
let current: IteratorResult<{ success: boolean }>;
do {
prev = current;
current = await i.next();
} while (!current.done);
// This is a workaround to fix an issue that only happens with
// the @angular-devkit/build-angular:browser builder. Starting
// on version 12.0.1, a SASS compilation implementation was
// introduced making use of workers and it's unref()-ing the worker
// too early, causing the process to exit early in environments
// like CI or when running Docker builds.
const keepProcessAliveInterval = setInterval(() => {}, 1000);
try {
let prev: IteratorResult<{ success: boolean }>;
let current: IteratorResult<{ success: boolean }>;
do {
prev = current;
current = await i.next();
} while (!current.done);

success =
current.value !== undefined || !prev
? current.value.success
: prev.value.success;
success =
current.value !== undefined || !prev
? current.value.success
: prev.value.success;

return success ? 0 : 1;
return success ? 0 : 1;
} finally {
clearInterval(keepProcessAliveInterval);
}
}

function createImplicitTargetConfig(
Expand Down

0 comments on commit 64f3ed3

Please sign in to comment.