Skip to content

Commit

Permalink
exit migration with error if it fails (#1581)
Browse files Browse the repository at this point in the history
  • Loading branch information
lkostrowski authored Sep 20, 2024
1 parent e7e47bf commit d6a4c54
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/six-gifts-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@saleor/webhook-utils": patch
---

Migrations will now exit with error (1) if error occurs
21 changes: 16 additions & 5 deletions packages/webhook-utils/src/webhook-migration-runner.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { WebhookManifest } from "@saleor/app-sdk/types";
import { Client } from "urql";

import { AppPermissionDeniedError, NetworkError, UnknownConnectionError } from "./errors";
import {
AppDetails,
getAppDetailsAndWebhooksData,
} from "./operations/get-app-details-and-webhooks-data";
import {
SaleorInstanceDetails,
getSaleorInstanceDetails,
SaleorInstanceDetails,
} from "./operations/get-saleor-instance-details";
import { Logger } from "./types";
import { WebhookUpdater } from "./webhook-updater";
Expand Down Expand Up @@ -75,12 +76,22 @@ export class WebhookMigrationRunner {
});
break;
case error instanceof UnknownConnectionError:
logger.error(`Migration finished with error while fetching data from Saleor`, {
error,
});
logger.error(
`Migration finished with error while fetching data from Saleor. Aborting...`,
{
error,
},
);

process.exit(1);

break;
default:
logger.error(`Migration finished with error while running migrations`, { error });
logger.error(`Migration finished with error while running migrations. Aborting...`, {
error,
});

process.exit(1);
}
}
};
Expand Down

0 comments on commit d6a4c54

Please sign in to comment.