From 6a5123a1b2d2b40089c94109619c471b3c33acf2 Mon Sep 17 00:00:00 2001 From: Rudolf Meijering Date: Tue, 28 Sep 2021 15:24:43 +0200 Subject: [PATCH 1/5] Refactor state types --- .../server/saved_objects/migrationsv2/actions/transform_docs.ts | 2 +- src/core/server/saved_objects/migrationsv2/index.ts | 2 +- src/core/server/saved_objects/migrationsv2/initial_state.ts | 2 +- .../migrationsv2/migrations_state_action_machine.test.ts | 2 +- .../migrationsv2/migrations_state_action_machine.ts | 2 +- .../migrationsv2/migrations_state_machine_cleanup.ts | 2 +- src/core/server/saved_objects/migrationsv2/model/helpers.ts | 2 +- src/core/server/saved_objects/migrationsv2/model/model.test.ts | 2 +- src/core/server/saved_objects/migrationsv2/model/model.ts | 2 +- .../server/saved_objects/migrationsv2/model/progress.test.ts | 2 +- src/core/server/saved_objects/migrationsv2/model/progress.ts | 2 +- .../server/saved_objects/migrationsv2/model/retry_state.test.ts | 2 +- src/core/server/saved_objects/migrationsv2/model/retry_state.ts | 2 +- src/core/server/saved_objects/migrationsv2/next.test.ts | 2 +- src/core/server/saved_objects/migrationsv2/next.ts | 2 +- .../server/saved_objects/migrationsv2/{types.ts => state.ts} | 0 16 files changed, 15 insertions(+), 15 deletions(-) rename src/core/server/saved_objects/migrationsv2/{types.ts => state.ts} (100%) diff --git a/src/core/server/saved_objects/migrationsv2/actions/transform_docs.ts b/src/core/server/saved_objects/migrationsv2/actions/transform_docs.ts index 4c712afcff3a4..41fa3b74dbc56 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/transform_docs.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/transform_docs.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ import * as TaskEither from 'fp-ts/lib/TaskEither'; -import type { TransformRawDocs } from '../types'; +import type { TransformRawDocs } from '../state'; import type { SavedObjectsRawDoc } from '../../serialization'; import { DocumentsTransformFailed, diff --git a/src/core/server/saved_objects/migrationsv2/index.ts b/src/core/server/saved_objects/migrationsv2/index.ts index 33f73395bcc6c..6f3878a8477f7 100644 --- a/src/core/server/saved_objects/migrationsv2/index.ts +++ b/src/core/server/saved_objects/migrationsv2/index.ts @@ -10,7 +10,7 @@ import { ElasticsearchClient } from '../../elasticsearch'; import { IndexMapping } from '../mappings'; import { Logger } from '../../logging'; import type { SavedObjectsMigrationVersion } from '../types'; -import type { TransformRawDocs } from './types'; +import type { TransformRawDocs } from './state'; import { MigrationResult } from '../migrations/core'; import { next } from './next'; import { model } from './model'; diff --git a/src/core/server/saved_objects/migrationsv2/initial_state.ts b/src/core/server/saved_objects/migrationsv2/initial_state.ts index a61967be9242c..f074f123c8930 100644 --- a/src/core/server/saved_objects/migrationsv2/initial_state.ts +++ b/src/core/server/saved_objects/migrationsv2/initial_state.ts @@ -11,7 +11,7 @@ import { IndexMapping } from '../mappings'; import { SavedObjectsMigrationVersion } from '../../../types'; import { SavedObjectsMigrationConfigType } from '../saved_objects_config'; import type { ISavedObjectTypeRegistry } from '../saved_objects_type_registry'; -import { InitState } from './types'; +import { InitState } from './state'; import { excludeUnusedTypesQuery } from '../migrations/core'; /** diff --git a/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.test.ts b/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.test.ts index 21468d7552320..cde851b692347 100644 --- a/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.test.ts +++ b/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.test.ts @@ -15,7 +15,7 @@ import * as Option from 'fp-ts/lib/Option'; import { ResponseError } from '@elastic/elasticsearch/lib/errors'; import { elasticsearchClientMock } from '../../elasticsearch/client/mocks'; import { LoggerAdapter } from '../../logging/logger_adapter'; -import { AllControlStates, State } from './types'; +import { AllControlStates, State } from './state'; import { createInitialState } from './initial_state'; import { ByteSizeValue } from '@kbn/config-schema'; diff --git a/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.ts b/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.ts index 3a5e592a8b9bf..87b78102371d3 100644 --- a/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.ts +++ b/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.ts @@ -13,7 +13,7 @@ import type { ElasticsearchClient } from '../../elasticsearch'; import { getErrorMessage, getRequestDebugMeta } from '../../elasticsearch'; import { Model, Next, stateActionMachine } from './state_action_machine'; import { cleanup } from './migrations_state_machine_cleanup'; -import { ReindexSourceToTempTransform, ReindexSourceToTempIndexBulk, State } from './types'; +import { ReindexSourceToTempTransform, ReindexSourceToTempIndexBulk, State } from './state'; import { SavedObjectsRawDoc } from '../serialization'; interface StateTransitionLogMeta extends LogMeta { diff --git a/src/core/server/saved_objects/migrationsv2/migrations_state_machine_cleanup.ts b/src/core/server/saved_objects/migrationsv2/migrations_state_machine_cleanup.ts index 9c0ef0d1a2cb6..ff8ff57d41ce4 100644 --- a/src/core/server/saved_objects/migrationsv2/migrations_state_machine_cleanup.ts +++ b/src/core/server/saved_objects/migrationsv2/migrations_state_machine_cleanup.ts @@ -8,7 +8,7 @@ import type { ElasticsearchClient } from '../../elasticsearch'; import * as Actions from './actions'; -import type { State } from './types'; +import type { State } from './state'; export async function cleanup(client: ElasticsearchClient, state?: State) { if (!state) return; diff --git a/src/core/server/saved_objects/migrationsv2/model/helpers.ts b/src/core/server/saved_objects/migrationsv2/model/helpers.ts index 4e920608594b1..c3a4c85679680 100644 --- a/src/core/server/saved_objects/migrationsv2/model/helpers.ts +++ b/src/core/server/saved_objects/migrationsv2/model/helpers.ts @@ -7,7 +7,7 @@ */ import { gt, valid } from 'semver'; -import { State } from '../types'; +import { State } from '../state'; import { IndexMapping } from '../../mappings'; import { FetchIndexResponse } from '../actions'; diff --git a/src/core/server/saved_objects/migrationsv2/model/model.test.ts b/src/core/server/saved_objects/migrationsv2/model/model.test.ts index 3e48a7147bffd..8ab306e09a960 100644 --- a/src/core/server/saved_objects/migrationsv2/model/model.test.ts +++ b/src/core/server/saved_objects/migrationsv2/model/model.test.ts @@ -40,7 +40,7 @@ import type { ReindexSourceToTempIndexBulk, CheckUnknownDocumentsState, CalculateExcludeFiltersState, -} from '../types'; +} from '../state'; import { SavedObjectsRawDoc } from '../../serialization'; import { TransformErrorObjects, TransformSavedObjectDocumentError } from '../../migrations/core'; import { AliasAction, RetryableEsClientError } from '../actions'; diff --git a/src/core/server/saved_objects/migrationsv2/model/model.ts b/src/core/server/saved_objects/migrationsv2/model/model.ts index 5d8862e48df1a..0b15e2ce411f2 100644 --- a/src/core/server/saved_objects/migrationsv2/model/model.ts +++ b/src/core/server/saved_objects/migrationsv2/model/model.ts @@ -11,7 +11,7 @@ import * as Option from 'fp-ts/lib/Option'; import { estypes } from '@elastic/elasticsearch'; import { AliasAction, isLeftTypeof } from '../actions'; -import { AllActionStates, MigrationLog, State } from '../types'; +import { AllActionStates, MigrationLog, State } from '../state'; import type { ResponseType } from '../next'; import { disableUnknownTypeMappingFields } from '../../migrations/core/migration_context'; import { diff --git a/src/core/server/saved_objects/migrationsv2/model/progress.test.ts b/src/core/server/saved_objects/migrationsv2/model/progress.test.ts index 2086774dd2fb4..c21d3ae015ee9 100644 --- a/src/core/server/saved_objects/migrationsv2/model/progress.test.ts +++ b/src/core/server/saved_objects/migrationsv2/model/progress.test.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { MigrationLog } from '../types'; +import type { MigrationLog } from '../state'; import { createInitialProgress, incrementProcessedProgress, diff --git a/src/core/server/saved_objects/migrationsv2/model/progress.ts b/src/core/server/saved_objects/migrationsv2/model/progress.ts index ef66283fcf682..c164cc3ef343d 100644 --- a/src/core/server/saved_objects/migrationsv2/model/progress.ts +++ b/src/core/server/saved_objects/migrationsv2/model/progress.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { MigrationLog, Progress } from '../types'; +import type { MigrationLog, Progress } from '../state'; /** * Returns an initial state of the progress object (everything undefined) diff --git a/src/core/server/saved_objects/migrationsv2/model/retry_state.test.ts b/src/core/server/saved_objects/migrationsv2/model/retry_state.test.ts index d49e570e0cdef..5a195f8597182 100644 --- a/src/core/server/saved_objects/migrationsv2/model/retry_state.test.ts +++ b/src/core/server/saved_objects/migrationsv2/model/retry_state.test.ts @@ -7,7 +7,7 @@ */ import { resetRetryState, delayRetryState } from './retry_state'; -import { State } from '../types'; +import { State } from '../state'; const createState = (parts: Record) => { return parts as State; diff --git a/src/core/server/saved_objects/migrationsv2/model/retry_state.ts b/src/core/server/saved_objects/migrationsv2/model/retry_state.ts index 5d69d32a7160c..02057a6af2061 100644 --- a/src/core/server/saved_objects/migrationsv2/model/retry_state.ts +++ b/src/core/server/saved_objects/migrationsv2/model/retry_state.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { State } from '../types'; +import { State } from '../state'; export const delayRetryState = ( state: S, diff --git a/src/core/server/saved_objects/migrationsv2/next.test.ts b/src/core/server/saved_objects/migrationsv2/next.test.ts index a34480fc311cd..98a8690844872 100644 --- a/src/core/server/saved_objects/migrationsv2/next.test.ts +++ b/src/core/server/saved_objects/migrationsv2/next.test.ts @@ -8,7 +8,7 @@ import { ElasticsearchClient } from '../../elasticsearch'; import { next } from './next'; -import { State } from './types'; +import { State } from './state'; describe('migrations v2 next', () => { it.todo('when state.retryDelay > 0 delays execution of the next action'); diff --git a/src/core/server/saved_objects/migrationsv2/next.ts b/src/core/server/saved_objects/migrationsv2/next.ts index 433c0998f7567..97bc54d367436 100644 --- a/src/core/server/saved_objects/migrationsv2/next.ts +++ b/src/core/server/saved_objects/migrationsv2/next.ts @@ -41,7 +41,7 @@ import type { OutdatedDocumentsRefresh, CheckUnknownDocumentsState, CalculateExcludeFiltersState, -} from './types'; +} from './state'; import * as Actions from './actions'; import { ElasticsearchClient } from '../../elasticsearch'; diff --git a/src/core/server/saved_objects/migrationsv2/types.ts b/src/core/server/saved_objects/migrationsv2/state.ts similarity index 100% rename from src/core/server/saved_objects/migrationsv2/types.ts rename to src/core/server/saved_objects/migrationsv2/state.ts From 90d3e655d4fe5e3159937b800eff9209c4b9a011 Mon Sep 17 00:00:00 2001 From: Rudolf Meijering Date: Fri, 1 Oct 2021 13:59:03 +0200 Subject: [PATCH 2/5] Log the stack trace of unhandled promise rejections --- .../environment/environment_service.test.ts | 27 +++++++++++++++++++ .../server/environment/environment_service.ts | 5 ++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/core/server/environment/environment_service.test.ts b/src/core/server/environment/environment_service.test.ts index 34647d090b995..ecfc9e5cc447c 100644 --- a/src/core/server/environment/environment_service.test.ts +++ b/src/core/server/environment/environment_service.test.ts @@ -17,6 +17,7 @@ import { CoreContext } from '../core_context'; import { configServiceMock } from '../config/mocks'; import { loggingSystemMock } from '../logging/logging_system.mock'; import { mockCoreContext } from '../core_context.mock'; +import { loggingServiceMock } from '../logging/logging_service.mock'; jest.mock('./resolve_uuid', () => ({ resolveInstanceUuid: jest.fn().mockResolvedValue('SOME_UUID'), @@ -135,6 +136,32 @@ describe('UuidService', () => { expect(logger.get('process').warn).not.toHaveBeenCalled(); }); }); + + describe('unhandledRejection warnings', () => { + it('logs warn for an unhandeld promise rejected with an Error', async () => { + await service.preboot(); + + const err = new Error('something went wrong'); + process.emit('unhandledRejection', err, new Promise((res, rej) => rej(err))); + + expect(logger.get('process').warn).toHaveBeenCalledTimes(1); + expect(loggingSystemMock.collect(logger).warn[0][0]).toMatch( + /Detected an unhandled Promise rejection: Error: something went wrong\n.*at Object. \(/ + ); + }); + + it('logs warn for an unhandeld promise rejected with a string', async () => { + await service.preboot(); + + const err = 'something went wrong'; + process.emit('unhandledRejection', err, new Promise((res, rej) => rej(err))); + + expect(logger.get('process').warn).toHaveBeenCalledTimes(1); + expect(loggingSystemMock.collect(logger).warn[0][0]).toMatch( + /Detected an unhandled Promise rejection: "something went wrong"/ + ); + }); + }); }); describe('#setup()', () => { diff --git a/src/core/server/environment/environment_service.ts b/src/core/server/environment/environment_service.ts index f96b616256577..472883c1f482c 100644 --- a/src/core/server/environment/environment_service.ts +++ b/src/core/server/environment/environment_service.ts @@ -54,9 +54,10 @@ export class EnvironmentService { this.configService.atPath(pidConfigDef.path).pipe(take(1)).toPromise(), ]); - // was present in the legacy `pid` file. + // Log unhandled rejections so that we can fix them in preparation for https://github.com/elastic/kibana/issues/77469 process.on('unhandledRejection', (reason) => { - this.log.warn(`Detected an unhandled Promise rejection.\n${reason}`); + const message = (reason as Error)?.stack ?? JSON.stringify(reason); + this.log.warn(`Detected an unhandled Promise rejection: ${message}`); }); process.on('warning', (warning) => { From c6e890d660aa8211ba611b168a4f5bf46cae86e6 Mon Sep 17 00:00:00 2001 From: Rudolf Meijering Date: Fri, 1 Oct 2021 14:13:06 +0200 Subject: [PATCH 3/5] Revert "Refactor state types" This reverts commit 6a5123a1b2d2b40089c94109619c471b3c33acf2. --- .../server/saved_objects/migrationsv2/actions/transform_docs.ts | 2 +- src/core/server/saved_objects/migrationsv2/index.ts | 2 +- src/core/server/saved_objects/migrationsv2/initial_state.ts | 2 +- .../migrationsv2/migrations_state_action_machine.test.ts | 2 +- .../migrationsv2/migrations_state_action_machine.ts | 2 +- .../migrationsv2/migrations_state_machine_cleanup.ts | 2 +- src/core/server/saved_objects/migrationsv2/model/helpers.ts | 2 +- src/core/server/saved_objects/migrationsv2/model/model.test.ts | 2 +- src/core/server/saved_objects/migrationsv2/model/model.ts | 2 +- .../server/saved_objects/migrationsv2/model/progress.test.ts | 2 +- src/core/server/saved_objects/migrationsv2/model/progress.ts | 2 +- .../server/saved_objects/migrationsv2/model/retry_state.test.ts | 2 +- src/core/server/saved_objects/migrationsv2/model/retry_state.ts | 2 +- src/core/server/saved_objects/migrationsv2/next.test.ts | 2 +- src/core/server/saved_objects/migrationsv2/next.ts | 2 +- .../server/saved_objects/migrationsv2/{state.ts => types.ts} | 0 16 files changed, 15 insertions(+), 15 deletions(-) rename src/core/server/saved_objects/migrationsv2/{state.ts => types.ts} (100%) diff --git a/src/core/server/saved_objects/migrationsv2/actions/transform_docs.ts b/src/core/server/saved_objects/migrationsv2/actions/transform_docs.ts index 41fa3b74dbc56..4c712afcff3a4 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/transform_docs.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/transform_docs.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ import * as TaskEither from 'fp-ts/lib/TaskEither'; -import type { TransformRawDocs } from '../state'; +import type { TransformRawDocs } from '../types'; import type { SavedObjectsRawDoc } from '../../serialization'; import { DocumentsTransformFailed, diff --git a/src/core/server/saved_objects/migrationsv2/index.ts b/src/core/server/saved_objects/migrationsv2/index.ts index 6f3878a8477f7..33f73395bcc6c 100644 --- a/src/core/server/saved_objects/migrationsv2/index.ts +++ b/src/core/server/saved_objects/migrationsv2/index.ts @@ -10,7 +10,7 @@ import { ElasticsearchClient } from '../../elasticsearch'; import { IndexMapping } from '../mappings'; import { Logger } from '../../logging'; import type { SavedObjectsMigrationVersion } from '../types'; -import type { TransformRawDocs } from './state'; +import type { TransformRawDocs } from './types'; import { MigrationResult } from '../migrations/core'; import { next } from './next'; import { model } from './model'; diff --git a/src/core/server/saved_objects/migrationsv2/initial_state.ts b/src/core/server/saved_objects/migrationsv2/initial_state.ts index f074f123c8930..a61967be9242c 100644 --- a/src/core/server/saved_objects/migrationsv2/initial_state.ts +++ b/src/core/server/saved_objects/migrationsv2/initial_state.ts @@ -11,7 +11,7 @@ import { IndexMapping } from '../mappings'; import { SavedObjectsMigrationVersion } from '../../../types'; import { SavedObjectsMigrationConfigType } from '../saved_objects_config'; import type { ISavedObjectTypeRegistry } from '../saved_objects_type_registry'; -import { InitState } from './state'; +import { InitState } from './types'; import { excludeUnusedTypesQuery } from '../migrations/core'; /** diff --git a/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.test.ts b/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.test.ts index cde851b692347..21468d7552320 100644 --- a/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.test.ts +++ b/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.test.ts @@ -15,7 +15,7 @@ import * as Option from 'fp-ts/lib/Option'; import { ResponseError } from '@elastic/elasticsearch/lib/errors'; import { elasticsearchClientMock } from '../../elasticsearch/client/mocks'; import { LoggerAdapter } from '../../logging/logger_adapter'; -import { AllControlStates, State } from './state'; +import { AllControlStates, State } from './types'; import { createInitialState } from './initial_state'; import { ByteSizeValue } from '@kbn/config-schema'; diff --git a/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.ts b/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.ts index 87b78102371d3..3a5e592a8b9bf 100644 --- a/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.ts +++ b/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.ts @@ -13,7 +13,7 @@ import type { ElasticsearchClient } from '../../elasticsearch'; import { getErrorMessage, getRequestDebugMeta } from '../../elasticsearch'; import { Model, Next, stateActionMachine } from './state_action_machine'; import { cleanup } from './migrations_state_machine_cleanup'; -import { ReindexSourceToTempTransform, ReindexSourceToTempIndexBulk, State } from './state'; +import { ReindexSourceToTempTransform, ReindexSourceToTempIndexBulk, State } from './types'; import { SavedObjectsRawDoc } from '../serialization'; interface StateTransitionLogMeta extends LogMeta { diff --git a/src/core/server/saved_objects/migrationsv2/migrations_state_machine_cleanup.ts b/src/core/server/saved_objects/migrationsv2/migrations_state_machine_cleanup.ts index ff8ff57d41ce4..9c0ef0d1a2cb6 100644 --- a/src/core/server/saved_objects/migrationsv2/migrations_state_machine_cleanup.ts +++ b/src/core/server/saved_objects/migrationsv2/migrations_state_machine_cleanup.ts @@ -8,7 +8,7 @@ import type { ElasticsearchClient } from '../../elasticsearch'; import * as Actions from './actions'; -import type { State } from './state'; +import type { State } from './types'; export async function cleanup(client: ElasticsearchClient, state?: State) { if (!state) return; diff --git a/src/core/server/saved_objects/migrationsv2/model/helpers.ts b/src/core/server/saved_objects/migrationsv2/model/helpers.ts index c3a4c85679680..4e920608594b1 100644 --- a/src/core/server/saved_objects/migrationsv2/model/helpers.ts +++ b/src/core/server/saved_objects/migrationsv2/model/helpers.ts @@ -7,7 +7,7 @@ */ import { gt, valid } from 'semver'; -import { State } from '../state'; +import { State } from '../types'; import { IndexMapping } from '../../mappings'; import { FetchIndexResponse } from '../actions'; diff --git a/src/core/server/saved_objects/migrationsv2/model/model.test.ts b/src/core/server/saved_objects/migrationsv2/model/model.test.ts index 8ab306e09a960..3e48a7147bffd 100644 --- a/src/core/server/saved_objects/migrationsv2/model/model.test.ts +++ b/src/core/server/saved_objects/migrationsv2/model/model.test.ts @@ -40,7 +40,7 @@ import type { ReindexSourceToTempIndexBulk, CheckUnknownDocumentsState, CalculateExcludeFiltersState, -} from '../state'; +} from '../types'; import { SavedObjectsRawDoc } from '../../serialization'; import { TransformErrorObjects, TransformSavedObjectDocumentError } from '../../migrations/core'; import { AliasAction, RetryableEsClientError } from '../actions'; diff --git a/src/core/server/saved_objects/migrationsv2/model/model.ts b/src/core/server/saved_objects/migrationsv2/model/model.ts index 0b15e2ce411f2..5d8862e48df1a 100644 --- a/src/core/server/saved_objects/migrationsv2/model/model.ts +++ b/src/core/server/saved_objects/migrationsv2/model/model.ts @@ -11,7 +11,7 @@ import * as Option from 'fp-ts/lib/Option'; import { estypes } from '@elastic/elasticsearch'; import { AliasAction, isLeftTypeof } from '../actions'; -import { AllActionStates, MigrationLog, State } from '../state'; +import { AllActionStates, MigrationLog, State } from '../types'; import type { ResponseType } from '../next'; import { disableUnknownTypeMappingFields } from '../../migrations/core/migration_context'; import { diff --git a/src/core/server/saved_objects/migrationsv2/model/progress.test.ts b/src/core/server/saved_objects/migrationsv2/model/progress.test.ts index c21d3ae015ee9..2086774dd2fb4 100644 --- a/src/core/server/saved_objects/migrationsv2/model/progress.test.ts +++ b/src/core/server/saved_objects/migrationsv2/model/progress.test.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { MigrationLog } from '../state'; +import type { MigrationLog } from '../types'; import { createInitialProgress, incrementProcessedProgress, diff --git a/src/core/server/saved_objects/migrationsv2/model/progress.ts b/src/core/server/saved_objects/migrationsv2/model/progress.ts index c164cc3ef343d..ef66283fcf682 100644 --- a/src/core/server/saved_objects/migrationsv2/model/progress.ts +++ b/src/core/server/saved_objects/migrationsv2/model/progress.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { MigrationLog, Progress } from '../state'; +import type { MigrationLog, Progress } from '../types'; /** * Returns an initial state of the progress object (everything undefined) diff --git a/src/core/server/saved_objects/migrationsv2/model/retry_state.test.ts b/src/core/server/saved_objects/migrationsv2/model/retry_state.test.ts index 5a195f8597182..d49e570e0cdef 100644 --- a/src/core/server/saved_objects/migrationsv2/model/retry_state.test.ts +++ b/src/core/server/saved_objects/migrationsv2/model/retry_state.test.ts @@ -7,7 +7,7 @@ */ import { resetRetryState, delayRetryState } from './retry_state'; -import { State } from '../state'; +import { State } from '../types'; const createState = (parts: Record) => { return parts as State; diff --git a/src/core/server/saved_objects/migrationsv2/model/retry_state.ts b/src/core/server/saved_objects/migrationsv2/model/retry_state.ts index 02057a6af2061..5d69d32a7160c 100644 --- a/src/core/server/saved_objects/migrationsv2/model/retry_state.ts +++ b/src/core/server/saved_objects/migrationsv2/model/retry_state.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { State } from '../state'; +import { State } from '../types'; export const delayRetryState = ( state: S, diff --git a/src/core/server/saved_objects/migrationsv2/next.test.ts b/src/core/server/saved_objects/migrationsv2/next.test.ts index 98a8690844872..a34480fc311cd 100644 --- a/src/core/server/saved_objects/migrationsv2/next.test.ts +++ b/src/core/server/saved_objects/migrationsv2/next.test.ts @@ -8,7 +8,7 @@ import { ElasticsearchClient } from '../../elasticsearch'; import { next } from './next'; -import { State } from './state'; +import { State } from './types'; describe('migrations v2 next', () => { it.todo('when state.retryDelay > 0 delays execution of the next action'); diff --git a/src/core/server/saved_objects/migrationsv2/next.ts b/src/core/server/saved_objects/migrationsv2/next.ts index 97bc54d367436..433c0998f7567 100644 --- a/src/core/server/saved_objects/migrationsv2/next.ts +++ b/src/core/server/saved_objects/migrationsv2/next.ts @@ -41,7 +41,7 @@ import type { OutdatedDocumentsRefresh, CheckUnknownDocumentsState, CalculateExcludeFiltersState, -} from './state'; +} from './types'; import * as Actions from './actions'; import { ElasticsearchClient } from '../../elasticsearch'; diff --git a/src/core/server/saved_objects/migrationsv2/state.ts b/src/core/server/saved_objects/migrationsv2/types.ts similarity index 100% rename from src/core/server/saved_objects/migrationsv2/state.ts rename to src/core/server/saved_objects/migrationsv2/types.ts From e2a287cd0a812109fcb8192f67567183200a9dc0 Mon Sep 17 00:00:00 2001 From: Rudolf Meijering Date: Fri, 1 Oct 2021 16:00:34 +0200 Subject: [PATCH 4/5] Fix types --- src/core/server/environment/environment_service.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/server/environment/environment_service.test.ts b/src/core/server/environment/environment_service.test.ts index ecfc9e5cc447c..a2a003d5c897c 100644 --- a/src/core/server/environment/environment_service.test.ts +++ b/src/core/server/environment/environment_service.test.ts @@ -17,7 +17,6 @@ import { CoreContext } from '../core_context'; import { configServiceMock } from '../config/mocks'; import { loggingSystemMock } from '../logging/logging_system.mock'; import { mockCoreContext } from '../core_context.mock'; -import { loggingServiceMock } from '../logging/logging_service.mock'; jest.mock('./resolve_uuid', () => ({ resolveInstanceUuid: jest.fn().mockResolvedValue('SOME_UUID'), From 4ea99e842ce9e6abda29fff0dbf92ebb1e42a36f Mon Sep 17 00:00:00 2001 From: Rudolf Meijering Date: Mon, 11 Oct 2021 21:48:43 +0200 Subject: [PATCH 5/5] code review feedback --- src/core/server/environment/environment_service.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/server/environment/environment_service.test.ts b/src/core/server/environment/environment_service.test.ts index a2a003d5c897c..4b074482248b4 100644 --- a/src/core/server/environment/environment_service.test.ts +++ b/src/core/server/environment/environment_service.test.ts @@ -145,7 +145,7 @@ describe('UuidService', () => { expect(logger.get('process').warn).toHaveBeenCalledTimes(1); expect(loggingSystemMock.collect(logger).warn[0][0]).toMatch( - /Detected an unhandled Promise rejection: Error: something went wrong\n.*at Object. \(/ + /Detected an unhandled Promise rejection: Error: something went wrong\n.*at / ); });