From d2b457b2e4dcdb05d16db5345e5d144edee5c798 Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Mon, 10 Mar 2025 06:28:39 +0700 Subject: [PATCH] fix(developer): load Keyman Developer options in Server before use Fixes: #13420 --- .../src/common/web/utils/src/utils/options.ts | 6 ++--- developer/src/server/src/index.ts | 27 +++++++++++-------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/developer/src/common/web/utils/src/utils/options.ts b/developer/src/common/web/utils/src/utils/options.ts index df32a4a7b9..9d1a93895e 100644 --- a/developer/src/common/web/utils/src/utils/options.ts +++ b/developer/src/common/web/utils/src/utils/options.ts @@ -1,6 +1,6 @@ -import * as os from 'os'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as os from 'node:os'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; export interface KeymanDeveloperOptions { "use tab char"?: boolean; diff --git a/developer/src/server/src/index.ts b/developer/src/server/src/index.ts index eed84f3b1a..677c5a7cd5 100644 --- a/developer/src/server/src/index.ts +++ b/developer/src/server/src/index.ts @@ -1,16 +1,16 @@ -import { environment } from './environment.js'; -import { KeymanSentry } from '@keymanapp/developer-utils'; -import express from 'express'; -import * as ws from 'ws'; -import * as os from 'os'; -import multer from 'multer'; -import * as fs from 'fs'; -import * as path from 'path'; -import setupRoutes from './routes.js'; -import { configuration } from './config.js'; -import { initTray } from './tray.js'; +import * as fs from 'node:fs'; +import * as os from 'node:os'; +import * as path from 'node:path'; import chalk from 'chalk'; +import express from 'express'; +import multer from 'multer'; +import * as ws from 'ws'; +import { KeymanSentry, loadOptions } from '@keymanapp/developer-utils'; +import { configuration } from './config.js'; +import { environment } from './environment.js'; +import setupRoutes from './routes.js'; import { shutdown } from './shutdown.js'; +import { initTray } from './tray.js'; const options = { ngrokLog: false, // Set this to true if you need to see ngrok logs in the console @@ -20,6 +20,11 @@ const options = { console.log(`Starting Keyman Developer Server ${environment.versionWithTag}, listening on port ${configuration.port}.`); +// We need to load the Keyman Developer options before attempting to initialize +// Sentry. `loadOptions` silently suppresses exceptions and returns a default +// set of options if an error occurs. +await loadOptions(); + KeymanSentry.init(); try { await run();