Skip to content

Commit

Permalink
refactor(@angular/build): adjust code to propagate errors from Piscina
Browse files Browse the repository at this point in the history
Ensure that errors occurring during initialization are properly propagated,
as Piscina currently swallows errors during worker initialization.
For more details, see:
https://github.com/piscinajs/piscina/blob/b64747233446ca4271e6aed744a740f637e278a5/src/worker.ts#L57

(cherry picked from commit a6eaf2f)
  • Loading branch information
alan-agius4 committed Nov 21, 2024
1 parent 919f5b9 commit 6a87b1e
Showing 1 changed file with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ const { outputMode, hasSsrEntry } = workerData as {
hasSsrEntry: boolean;
};

let serverURL = DEFAULT_URL;

/** Renders an application based on a provided options. */
async function extractRoutes(): Promise<RoutersExtractorWorkerResult> {
const serverURL = outputMode !== undefined && hasSsrEntry ? await launchServer() : DEFAULT_URL;

patchFetchToLoadInMemoryAssets(serverURL);

const { ɵextractRoutesAndCreateRouteTree: extractRoutesAndCreateRouteTree } =
await loadEsmModuleFromMemory('./main.server.mjs');

Expand All @@ -47,14 +49,4 @@ async function extractRoutes(): Promise<RoutersExtractorWorkerResult> {
};
}

async function initialize() {
if (outputMode !== undefined && hasSsrEntry) {
serverURL = await launchServer();
}

patchFetchToLoadInMemoryAssets(serverURL);

return extractRoutes;
}

export default initialize();
export default extractRoutes;

0 comments on commit 6a87b1e

Please sign in to comment.