import { text } from '@rsdk/common'; import { LoggerFactory } from '@rsdk/logging'; const logger = LoggerFactory.create('PlatformContext'); if (!process.env.RSDK_CLI_MODE) { logger.info('Registering unhandled rejections handler...'); } // This code enriches output if unhandled exceptions happen process.on('unhandledRejection', (reason: any, promise) => { logger.error( text` Unhandled promise rejection happened! Process is shutting down with exit code 1. See: https://github.com/nodejs/node/issues/20392 and https://nodejs.org/api/process.html#event-unhandledrejection `, { promise, reason }, ); /** * Additionally writes to standard console, because both and * can be not serializable */ console.error('Found unhandled rejection', { promise, reason, }); process.exit(1); });