Fix error messages on sign up (#10399)
In this PR: - adding logs to track workspace creation performance - refactor useIsWorkspaceSuspended to be more generic - only fetch favorites and views if workspace is Active to avoid error messages on sign up (workspace is not created yet)
This commit is contained in:
@ -80,6 +80,8 @@ export class WorkspaceSyncMetadataService {
|
||||
this.logger.log('Syncing standard objects and fields metadata');
|
||||
|
||||
// 1 - Sync standard objects
|
||||
|
||||
const workspaceObjectMigrationsStart = performance.now();
|
||||
const workspaceObjectMigrations =
|
||||
await this.workspaceSyncObjectMetadataService.synchronize(
|
||||
context,
|
||||
@ -88,7 +90,14 @@ export class WorkspaceSyncMetadataService {
|
||||
workspaceFeatureFlagsMap,
|
||||
);
|
||||
|
||||
const workspaceObjectMigrationsEnd = performance.now();
|
||||
|
||||
this.logger.log(
|
||||
`Workspace object migrations took ${workspaceObjectMigrationsEnd - workspaceObjectMigrationsStart}ms`,
|
||||
);
|
||||
|
||||
// 2 - Sync standard fields on standard and custom objects
|
||||
const workspaceFieldMigrationsStart = performance.now();
|
||||
const workspaceFieldMigrations =
|
||||
await this.workspaceSyncFieldMetadataService.synchronize(
|
||||
context,
|
||||
@ -97,7 +106,14 @@ export class WorkspaceSyncMetadataService {
|
||||
workspaceFeatureFlagsMap,
|
||||
);
|
||||
|
||||
const workspaceFieldMigrationsEnd = performance.now();
|
||||
|
||||
this.logger.log(
|
||||
`Workspace field migrations took ${workspaceFieldMigrationsEnd - workspaceFieldMigrationsStart}ms`,
|
||||
);
|
||||
|
||||
// 3 - Sync standard relations on standard and custom objects
|
||||
const workspaceRelationMigrationsStart = performance.now();
|
||||
const workspaceRelationMigrations =
|
||||
await this.workspaceSyncRelationMetadataService.synchronize(
|
||||
context,
|
||||
@ -106,7 +122,14 @@ export class WorkspaceSyncMetadataService {
|
||||
workspaceFeatureFlagsMap,
|
||||
);
|
||||
|
||||
const workspaceRelationMigrationsEnd = performance.now();
|
||||
|
||||
this.logger.log(
|
||||
`Workspace relation migrations took ${workspaceRelationMigrationsEnd - workspaceRelationMigrationsStart}ms`,
|
||||
);
|
||||
|
||||
// 4 - Sync standard indexes on standard objects
|
||||
const workspaceIndexMigrationsStart = performance.now();
|
||||
const workspaceIndexMigrations =
|
||||
await this.workspaceSyncIndexMetadataService.synchronize(
|
||||
context,
|
||||
@ -115,7 +138,15 @@ export class WorkspaceSyncMetadataService {
|
||||
workspaceFeatureFlagsMap,
|
||||
);
|
||||
|
||||
const workspaceIndexMigrationsEnd = performance.now();
|
||||
|
||||
this.logger.log(
|
||||
`Workspace index migrations took ${workspaceIndexMigrationsEnd - workspaceIndexMigrationsStart}ms`,
|
||||
);
|
||||
|
||||
// 5 - Sync standard object metadata identifiers, does not need to return nor apply migrations
|
||||
const workspaceObjectMetadataIdentifiersStart = performance.now();
|
||||
|
||||
await this.workspaceSyncObjectMetadataIdentifiersService.synchronize(
|
||||
context,
|
||||
manager,
|
||||
@ -123,6 +154,14 @@ export class WorkspaceSyncMetadataService {
|
||||
workspaceFeatureFlagsMap,
|
||||
);
|
||||
|
||||
const workspaceObjectMetadataIdentifiersEnd = performance.now();
|
||||
|
||||
this.logger.log(
|
||||
`Workspace object metadata identifiers took ${workspaceObjectMetadataIdentifiersEnd - workspaceObjectMetadataIdentifiersStart}ms`,
|
||||
);
|
||||
|
||||
const workspaceMigrationsSaveStart = performance.now();
|
||||
|
||||
// Save workspace migrations into the database
|
||||
workspaceMigrations = await workspaceMigrationRepository.save([
|
||||
...workspaceObjectMigrations,
|
||||
@ -131,6 +170,12 @@ export class WorkspaceSyncMetadataService {
|
||||
...workspaceIndexMigrations,
|
||||
]);
|
||||
|
||||
const workspaceMigrationsSaveEnd = performance.now();
|
||||
|
||||
this.logger.log(
|
||||
`Workspace migrations save took ${workspaceMigrationsSaveEnd - workspaceMigrationsSaveStart}ms`,
|
||||
);
|
||||
|
||||
// If we're running a dry run, rollback the transaction and do not execute migrations
|
||||
if (!options.applyChanges) {
|
||||
this.logger.log('Running in dry run mode, rolling back transaction');
|
||||
@ -149,9 +194,16 @@ export class WorkspaceSyncMetadataService {
|
||||
|
||||
// Execute migrations
|
||||
this.logger.log('Executing pending migrations');
|
||||
const executeMigrationsStart = performance.now();
|
||||
|
||||
await this.workspaceMigrationRunnerService.executeMigrationFromPendingMigrations(
|
||||
context.workspaceId,
|
||||
);
|
||||
const executeMigrationsEnd = performance.now();
|
||||
|
||||
this.logger.log(
|
||||
`Execute migrations took ${executeMigrationsEnd - executeMigrationsStart}ms`,
|
||||
);
|
||||
} catch (error) {
|
||||
this.logger.error('Sync of standard objects failed with:', error);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user