diff --git a/packages/builder/src/pages/builder/app/[application]/updating.svelte b/packages/builder/src/pages/builder/app/[application]/updating.svelte
index 4da91ed074..dca01e3495 100644
--- a/packages/builder/src/pages/builder/app/[application]/updating.svelte
+++ b/packages/builder/src/pages/builder/app/[application]/updating.svelte
@@ -4,13 +4,18 @@
import { API } from "api"
- let timeout
+ const timeoutMs = 60000 // 1 minute
+ const loadTime = Date.now()
+
async function checkMigrationsFinished() {
- timeout = setTimeout(async () => {
- const response = await API.get({ url: "/api/migrations/status" })
+ setTimeout(async () => {
+ const response = await API.getMigrationStatus()
if (!response.migrated) {
- checkMigrationsFinished()
- return
+ if (loadTime + timeoutMs > Date.now()) {
+ return checkMigrationsFinished()
+ }
+
+ return migrationTimeout()
}
const urlParams = new URLSearchParams(window.location.search)
@@ -22,11 +27,10 @@
checkMigrationsFinished()
- setTimeout(() => {
- clearTimeout(timeout)
+ function migrationTimeout() {
// TODO
alert("Something went wrong 💀")
- }, 60000)
+ }
diff --git a/packages/frontend-core/src/api/index.js b/packages/frontend-core/src/api/index.js
index d4b4f3636e..066ab16f6e 100644
--- a/packages/frontend-core/src/api/index.js
+++ b/packages/frontend-core/src/api/index.js
@@ -33,6 +33,7 @@ import { buildEnvironmentVariableEndpoints } from "./environmentVariables"
import { buildEventEndpoints } from "./events"
import { buildAuditLogsEndpoints } from "./auditLogs"
import { buildLogsEndpoints } from "./logs"
+import { buildMigrationEndpoints } from "./migrations"
/**
* Random identifier to uniquely identify a session in a tab. This is
@@ -298,6 +299,7 @@ export const createAPIClient = config => {
...buildEventEndpoints(API),
...buildAuditLogsEndpoints(API),
...buildLogsEndpoints(API),
+ ...buildMigrationEndpoints(API),
viewV2: buildViewV2Endpoints(API),
}
}
diff --git a/packages/frontend-core/src/api/migrations.js b/packages/frontend-core/src/api/migrations.js
new file mode 100644
index 0000000000..2da70d6fcb
--- /dev/null
+++ b/packages/frontend-core/src/api/migrations.js
@@ -0,0 +1,10 @@
+export const buildMigrationEndpoints = API => ({
+ /**
+ * Gets the info about the current app migration
+ */
+ getMigrationStatus: async () => {
+ return await API.get({
+ url: "/api/migrations/status",
+ })
+ },
+})