Skip to content

Commit

Permalink
Catch runPipelines error to retain invalidations
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Jan 10, 2022
1 parent 4733547 commit 7e4572f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
15 changes: 11 additions & 4 deletions packages/core/core/src/Transformation.js
Expand Up @@ -83,7 +83,8 @@ export type TransformationOpts = {|
|};

export type TransformationResult = {|
assets: Array<AssetValue>,
assets?: Array<AssetValue>,
error?: Error,
configRequests: Array<ConfigRequest>,
invalidations: Array<RequestInvalidation>,
invalidateOnFileCreate: Array<InternalFileCreateInvalidation>,
Expand Down Expand Up @@ -178,19 +179,25 @@ export default class Transformation {
asset.value.isSource,
asset.value.pipeline,
);
let results = await this.runPipelines(pipeline, asset);
let assets = results.map(a => a.value);
let assets, error;
try {
let results = await this.runPipelines(pipeline, asset);
assets = results.map(a => a.value);
} catch (e) {
error = e;
}

let configRequests = getConfigRequests([...this.configs.values()]);
let devDepRequests = getWorkerDevDepRequests([
...this.devDepRequests.values(),
]);

// $FlowFixMe
// $FlowFixMe because of $$raw
return {
$$raw: true,
assets,
configRequests,
error,
invalidateOnFileCreate: this.invalidateOnFileCreate,
invalidations: [...this.invalidations.values()],
devDepRequests,
Expand Down
13 changes: 10 additions & 3 deletions packages/core/core/src/requests/AssetRequest.js
Expand Up @@ -128,6 +128,7 @@ async function run({input, api, farm, invalidateReason, options}: RunInput) {
let {
assets,
configRequests,
error,
invalidations,
invalidateOnFileCreate,
devDepRequests,
Expand All @@ -138,8 +139,10 @@ async function run({input, api, farm, invalidateReason, options}: RunInput) {
}): TransformationResult);

let time = Date.now() - start;
for (let asset of assets) {
asset.stats.time = time;
if (assets) {
for (let asset of assets) {
asset.stats.time = time;
}
}

for (let invalidation of invalidateOnFileCreate) {
Expand Down Expand Up @@ -171,5 +174,9 @@ async function run({input, api, farm, invalidateReason, options}: RunInput) {
await runConfigRequest(api, configRequest);
}

return assets;
if (error != null) {
throw error;
} else {
return nullthrows(assets);
}
}

0 comments on commit 7e4572f

Please sign in to comment.