Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/core/packages/root/server-internal/src/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,17 @@ export async function bootstrap({ configs, cliArgs, applyConfigOverrides }: Boot
}
}

function onRootShutdown(reason?: any) {
if (reason !== undefined) {
if (reason.code !== MIGRATION_EXCEPTION_CODE) {
function onRootShutdown(error?: any) {
if (error !== undefined) {
if (error.code !== MIGRATION_EXCEPTION_CODE) {
// There is a chance that logger wasn't configured properly and error that
// that forced root to shut down could go unnoticed. To prevent this we always
// mirror such fatal errors in standard output with `console.error`.
// eslint-disable-next-line no-console
console.error(`\n${chalk.white.bgRed(' FATAL ')} ${reason}\n`);
console.error(`\n${chalk.white.bgRed(' FATAL ')} ${error}\n`);
}

process.exit(reason instanceof CriticalError ? reason.processExitCode : 1);
process.exit(error instanceof CriticalError ? error.processExitCode : 1);
}

process.exit(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { get } from 'lodash';
import { errors as esErrors } from '@elastic/elasticsearch';
import type { ErrorCause } from '@elastic/elasticsearch/lib/api/types';
import type { ElasticsearchErrorDetails } from '@kbn/es-errors';
import { isSupportedEsServer } from '@kbn/core-elasticsearch-server-internal';
import { SavedObjectsErrorHelpers } from '@kbn/core-saved-objects-server';
Expand Down Expand Up @@ -38,7 +39,10 @@ export function decorateEsError(error: EsErrors) {
throw new Error('Expected an instance of Error');
}

const { reason } = get(error, 'body.error', { reason: undefined }) as { reason?: string };
const { reason: esErrorReason } = get(error, 'body.error', {
reason: undefined,
}) as ErrorCause;
const reason = esErrorReason || undefined;
if (
error instanceof ConnectionError ||
error instanceof NoLivingConnectionsError ||
Expand Down