diff --git a/.buildkite/package-lock.json b/.buildkite/package-lock.json index c691fcebb17d5..1f19ccc524926 100644 --- a/.buildkite/package-lock.json +++ b/.buildkite/package-lock.json @@ -25,7 +25,7 @@ "@types/jscodeshift": "^0.12.0", "@types/minimatch": "^3.0.5", "@types/minimist": "^1.2.5", - "@types/node": "22.19.0", + "@types/node": "24.10.13", "jest": "^30.0.3", "jscodeshift": "^17.1.2", "nock": "^12.0.2", @@ -1930,13 +1930,13 @@ "dev": true }, "node_modules/@types/node": { - "version": "22.19.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.0.tgz", - "integrity": "sha512-xpr/lmLPQEj+TUnHmR+Ab91/glhJvsqcjB+yY0Ix9GO70H6Lb4FHH5GeqdOE5btAx7eIMwuHkp4H2MSkLcqWbA==", + "version": "24.10.13", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.13.tgz", + "integrity": "sha512-oH72nZRfDv9lADUBSo104Aq7gPHpQZc4BTx38r9xf9pg5LfP6EzSyH2n7qFmmxRQXh7YlUXODcYsg6PuTDSxGg==", "dev": true, "license": "MIT", "dependencies": { - "undici-types": "~6.21.0" + "undici-types": "~7.16.0" } }, "node_modules/@types/stack-utils": { @@ -5811,9 +5811,9 @@ } }, "node_modules/undici-types": { - "version": "6.21.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", - "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", + "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", "dev": true, "license": "MIT" }, @@ -7465,12 +7465,12 @@ "dev": true }, "@types/node": { - "version": "22.19.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.0.tgz", - "integrity": "sha512-xpr/lmLPQEj+TUnHmR+Ab91/glhJvsqcjB+yY0Ix9GO70H6Lb4FHH5GeqdOE5btAx7eIMwuHkp4H2MSkLcqWbA==", + "version": "24.10.13", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.13.tgz", + "integrity": "sha512-oH72nZRfDv9lADUBSo104Aq7gPHpQZc4BTx38r9xf9pg5LfP6EzSyH2n7qFmmxRQXh7YlUXODcYsg6PuTDSxGg==", "dev": true, "requires": { - "undici-types": "~6.21.0" + "undici-types": "~7.16.0" } }, "@types/stack-utils": { @@ -10046,9 +10046,9 @@ "dev": true }, "undici-types": { - "version": "6.21.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", - "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", + "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", "dev": true }, "universal-user-agent": { diff --git a/.buildkite/package.json b/.buildkite/package.json index afc91fc2713d0..e3cb4ed50a4c9 100644 --- a/.buildkite/package.json +++ b/.buildkite/package.json @@ -25,7 +25,7 @@ "@types/jscodeshift": "^0.12.0", "@types/minimatch": "^3.0.5", "@types/minimist": "^1.2.5", - "@types/node": "22.19.0", + "@types/node": "24.10.13", "jest": "^30.0.3", "jscodeshift": "^17.1.2", "nock": "^12.0.2", diff --git a/.node-version b/.node-version index 85e502778f623..8e35034890556 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -22.22.0 +24.14.1 diff --git a/.nvmrc b/.nvmrc index 85e502778f623..8e35034890556 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -22.22.0 +24.14.1 diff --git a/package.json b/package.json index d5c48b83152b4..d3efc7389f2c9 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "url": "https://github.com/elastic/kibana.git" }, "engines": { - "node": "22.22.0", + "node": "24.14.1", "yarn": "^1.22.19" }, "resolutions": { @@ -85,7 +85,7 @@ "**/@hono/node-server": "1.19.14", "**/@langchain/core": "1.1.31", "**/@langchain/google-common": "2.1.24", - "**/@types/node": "22.19.1", + "**/@types/node": "24.10.13", "**/@types/prop-types": "15.7.5", "**/@typescript-eslint/utils": "8.46.3", "**/baseline-browser-mapping": "2.9.14", @@ -1530,7 +1530,7 @@ "type-fest": "4.41.0", "typescript-fsa": "3.0.0", "typescript-fsa-reducers": "1.2.2", - "undici": "6.23.0", + "undici": "7.24.4", "unidiff": "1.0.4", "unified": "9.2.2", "use-resize-observer": "9.1.0", @@ -1949,7 +1949,7 @@ "@types/moment-duration-format": "2.2.7", "@types/mustache": "4.2.5", "@types/nock": "10.0.3", - "@types/node": "22.19.0", + "@types/node": "24.10.13", "@types/node-fetch": "2.6.4", "@types/node-forge": "1.3.14", "@types/nodemailer": "7.0.6", diff --git a/packages/kbn-plugin-helpers/src/tasks/optimize_worker.ts b/packages/kbn-plugin-helpers/src/tasks/optimize_worker.ts index de4c852fd16d6..67c2b05f85ffd 100644 --- a/packages/kbn-plugin-helpers/src/tasks/optimize_worker.ts +++ b/packages/kbn-plugin-helpers/src/tasks/optimize_worker.ts @@ -12,7 +12,7 @@ import type { WorkerConfig } from '@kbn/optimizer/src/common'; import { parseBundles, BundleRemotes } from '@kbn/optimizer/src/common'; import { getWebpackConfig } from '@kbn/optimizer/src/worker/webpack.config'; -const send = process.send; +const send = process.send?.bind(process); if (!send) { throw new Error('must be run as a node.js fork'); } @@ -36,25 +36,34 @@ process.on('message', (msg: any) => { }, (error, stats) => { if (error) { - send.call(process, { - success: false, - error: error.message, - }); + send( + { + success: false, + error: error.message, + }, + undefined + ); return; } if (stats?.hasErrors()) { - send.call(process, { - success: false, - error: `Failed to compile with webpack:\n${stats.toString()}`, - }); + send( + { + success: false, + error: `Failed to compile with webpack:\n${stats.toString()}`, + }, + undefined + ); return; } - send.call(process, { - success: true, - warnings: stats?.hasWarnings() ? stats.toString() : '', - }); + send( + { + success: true, + warnings: stats?.hasWarnings() ? stats.toString() : '', + }, + undefined + ); } ); }); diff --git a/packages/kbn-relocate/healthcheck.ts b/packages/kbn-relocate/healthcheck.ts index 5ebaf501cc701..39e03df792fe5 100644 --- a/packages/kbn-relocate/healthcheck.ts +++ b/packages/kbn-relocate/healthcheck.ts @@ -66,9 +66,9 @@ const checkIfResourceExists = (baseDir: string, reference: string): boolean => { const getAllFiles = ( dirPath: string, - arrayOfFiles: fs.Dirent[] = [], + arrayOfFiles: string[] = [], extensions?: string[] -): fs.Dirent[] => { +): string[] => { const files = fs.readdirSync(dirPath, { withFileTypes: true }); files.forEach((file) => { @@ -77,12 +77,10 @@ const getAllFiles = ( !EXCLUDED_FOLDERS.some((folder) => filePath.startsWith(join(BASE_FOLDER, folder))) && !EXCLUDED_FOLDER_NAMES.includes(file.name) ) { - if (fs.statSync(filePath).isDirectory()) { - arrayOfFiles = getAllFiles(filePath, arrayOfFiles); - } else { - if (!extensions || extensions.find((ext) => file.name.endsWith(ext))) { - arrayOfFiles.push(file); - } + if (file.isDirectory()) { + arrayOfFiles = getAllFiles(filePath, arrayOfFiles, extensions); + } else if (!extensions || extensions.find((ext) => file.name.endsWith(ext))) { + arrayOfFiles.push(filePath); } } }); @@ -95,14 +93,14 @@ export const findBrokenReferences = async (log: ToolingLog) => { const moduleNames = packages.map((pkg) => pkg.directory.split('/').pop()!); const files = getAllFiles(BASE_FOLDER, [], EXTENSIONS); - for (const file of files) { - const fileBrokenReferences = []; - const filePath = join(file.path, file.name); + for (const filePath of files) { + const fileBrokenReferences: string[] = []; + const baseDir = path.dirname(filePath); const content = fs.readFileSync(filePath, 'utf-8'); const references = findPaths(content); for (const ref of references) { - if (isModuleReference(moduleNames, ref) && !checkIfResourceExists(file.path, ref)) { + if (isModuleReference(moduleNames, ref) && !checkIfResourceExists(baseDir, ref)) { fileBrokenReferences.push(ref); } } @@ -116,9 +114,8 @@ export const findBrokenReferences = async (log: ToolingLog) => { export const findBrokenLinks = async (log: ToolingLog) => { const files = getAllFiles(BASE_FOLDER); - for (const file of files) { - const fileBrokenLinks = []; - const filePath = join(file.path, file.name); + for (const filePath of files) { + const fileBrokenLinks: string[] = []; const content = fs.readFileSync(filePath, 'utf-8'); const references = findUrls(content); diff --git a/packages/kbn-styled-components-mapping-cli/src/find_files.ts b/packages/kbn-styled-components-mapping-cli/src/find_files.ts index 8bbedf27ba515..e24506c7f0a8b 100644 --- a/packages/kbn-styled-components-mapping-cli/src/find_files.ts +++ b/packages/kbn-styled-components-mapping-cli/src/find_files.ts @@ -30,7 +30,7 @@ const walkDirectory = async (dirPath: string): Promise => { let usesOnlyStyledComponents = true; for (const file of await fs.readdir(dirPath, { withFileTypes: true })) { - const fullPath = path.join(file.path, file.name); + const fullPath = path.join(dirPath, file.name); if (file.isDirectory()) { const meta = await walkDirectory(fullPath); diff --git a/src/core/packages/elasticsearch/client-server-internal/src/get_agents_sockets_stats.test.ts b/src/core/packages/elasticsearch/client-server-internal/src/get_agents_sockets_stats.test.ts index 8b6fc71ffda1e..4bb124ebdbe4e 100644 --- a/src/core/packages/elasticsearch/client-server-internal/src/get_agents_sockets_stats.test.ts +++ b/src/core/packages/elasticsearch/client-server-internal/src/get_agents_sockets_stats.test.ts @@ -8,15 +8,14 @@ */ import { Socket } from 'net'; -import type { Agent } from 'http'; -import { IncomingMessage } from 'http'; +import type { Agent, ClientRequest } from 'http'; import { getAgentsSocketsStats } from './get_agents_sockets_stats'; import { getHttpAgentMock, getHttpsAgentMock } from './get_agents_sockets_stats.test.mocks'; jest.mock('net'); const mockSocket = new Socket(); -const mockIncomingMessage = new IncomingMessage(mockSocket); +const mockClientRequest = {} as unknown as ClientRequest; describe('getAgentsSocketsStats()', () => { it('extracts aggregated stats from the specified agents', () => { @@ -30,7 +29,7 @@ describe('getAgentsSocketsStats()', () => { node3: [mockSocket, mockSocket, mockSocket, mockSocket], }, requests: { - node1: [mockIncomingMessage, mockIncomingMessage], + node1: [mockClientRequest, mockClientRequest], }, }); @@ -43,7 +42,7 @@ describe('getAgentsSocketsStats()', () => { node3: [mockSocket, mockSocket, mockSocket, mockSocket], }, requests: { - node4: [mockIncomingMessage, mockIncomingMessage, mockIncomingMessage, mockIncomingMessage], + node4: [mockClientRequest, mockClientRequest, mockClientRequest, mockClientRequest], }, }); diff --git a/src/core/packages/http/router-server-internal/src/response_adapter.ts b/src/core/packages/http/router-server-internal/src/response_adapter.ts index 5b242161e1490..f46f2cc4f361e 100644 --- a/src/core/packages/http/router-server-internal/src/response_adapter.ts +++ b/src/core/packages/http/router-server-internal/src/response_adapter.ts @@ -173,7 +173,7 @@ function getErrorMessage(payload?: ResponseError): string { } function isStreamOrBuffer(payload: ResponseError): payload is stream.Stream | Buffer { - return Buffer.isBuffer(payload) || stream.isReadable(payload as stream.Readable); + return Buffer.isBuffer(payload) || stream.isReadable(payload as stream.Readable) === true; } function getErrorAttributes(payload?: ResponseError): ResponseErrorAttributes | undefined { diff --git a/src/dev/build/lib/get_build_number.ts b/src/dev/build/lib/get_build_number.ts index c5622ab6a1793..0fbd71d5ce18f 100644 --- a/src/dev/build/lib/get_build_number.ts +++ b/src/dev/build/lib/get_build_number.ts @@ -7,18 +7,9 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import os from 'os'; import execa from 'execa'; export async function getBuildNumber() { - if (/^win/.test(os.platform())) { - // Windows does not have the wc process and `find /C /V ""` does not consistently work - const log = await execa('git', ['log', '--format="%h"']); - return log.stdout.split('\n').length; - } - - const wc = await execa.command('git log --format="%h" | wc -l', { - shell: true, - }); - return parseFloat(wc.stdout.trim()); + const count = await execa('git', ['rev-list', '--count', 'HEAD']); + return parseFloat(count.stdout.trim()); } diff --git a/src/platform/packages/private/kbn-screenshotting-server/src/args.test.ts b/src/platform/packages/private/kbn-screenshotting-server/src/args.test.ts index 340c0a4158a7e..a02f771361f64 100644 --- a/src/platform/packages/private/kbn-screenshotting-server/src/args.test.ts +++ b/src/platform/packages/private/kbn-screenshotting-server/src/args.test.ts @@ -16,12 +16,13 @@ import { args } from './args'; describe('headless webgl arm mac workaround', () => { const originalPlatform = process.platform; afterEach(() => { + jest.restoreAllMocks(); Object.defineProperty(process, 'platform', { value: originalPlatform, }); }); - const simulateEnv = (platform: string, arch: string) => { + const simulateEnv = (platform: string, arch: ReturnType) => { Object.defineProperty(process, 'platform', { value: platform }); jest.spyOn(os, 'arch').mockReturnValue(arch); }; diff --git a/src/platform/packages/private/kbn-ui-shared-deps-npm/version_dependencies.txt b/src/platform/packages/private/kbn-ui-shared-deps-npm/version_dependencies.txt index cc5042cac3031..a509072872b41 100644 --- a/src/platform/packages/private/kbn-ui-shared-deps-npm/version_dependencies.txt +++ b/src/platform/packages/private/kbn-ui-shared-deps-npm/version_dependencies.txt @@ -61,7 +61,7 @@ @types/lodash@4.17.0 @types/mdast@3.0.3 @types/minimatch@3.0.3 -@types/node@22.19.1 +@types/node@24.10.13 @types/numeral@2.0.5 @types/parse-json@4.0.0 @types/parse5@5.0.3 @@ -485,7 +485,7 @@ tslib@1.14.1 tslib@2.8.1 tty-browserify@0.0.1 typed-array-buffer@1.0.3 -undici-types@6.21.0 +undici-types@7.16.0 unherit@1.1.0 unified@9.2.2 unist-builder@2.0.3 diff --git a/src/platform/packages/private/kbn-ui-shared-deps-src/version_dependencies.txt b/src/platform/packages/private/kbn-ui-shared-deps-src/version_dependencies.txt index aa7ca6678288a..4d8d44b25bad6 100644 --- a/src/platform/packages/private/kbn-ui-shared-deps-src/version_dependencies.txt +++ b/src/platform/packages/private/kbn-ui-shared-deps-src/version_dependencies.txt @@ -14,7 +14,7 @@ @types/estree@1.0.8 @types/js-cookie@2.2.6 @types/json-schema@7.0.11 -@types/node@22.19.1 +@types/node@24.10.13 @types/trusted-types@2.0.7 @webassemblyjs/ast@1.12.1 @webassemblyjs/floating-point-hex-parser@1.11.6 @@ -145,7 +145,7 @@ toggle-selection@1.0.6 ts-easing@0.2.0 tslib@1.14.1 tslib@2.8.1 -undici-types@6.21.0 +undici-types@7.16.0 update-browserslist-db@1.2.3 uri-js@4.2.2 util-deprecate@1.0.2 diff --git a/src/platform/packages/shared/kbn-monaco/version_dependencies.txt b/src/platform/packages/shared/kbn-monaco/version_dependencies.txt index db4cce6832968..45918c8e612c1 100644 --- a/src/platform/packages/shared/kbn-monaco/version_dependencies.txt +++ b/src/platform/packages/shared/kbn-monaco/version_dependencies.txt @@ -9,7 +9,7 @@ @types/estree@0.0.50 @types/estree@1.0.8 @types/json-schema@7.0.11 -@types/node@22.19.1 +@types/node@24.10.13 @webassemblyjs/ast@1.12.1 @webassemblyjs/floating-point-hex-parser@1.11.6 @webassemblyjs/helper-api-error@1.11.6 @@ -94,7 +94,7 @@ tapable@2.3.0 terser-webpack-plugin@5.3.17 terser@5.40.0 tslib@1.14.1 -undici-types@6.21.0 +undici-types@7.16.0 update-browserslist-db@1.2.3 uri-js@4.2.2 vscode-jsonrpc@8.2.0 diff --git a/src/platform/packages/shared/kbn-workspaces/src/bootstrap.ts b/src/platform/packages/shared/kbn-workspaces/src/bootstrap.ts index a4c33f168c909..9a7080fd37994 100644 --- a/src/platform/packages/shared/kbn-workspaces/src/bootstrap.ts +++ b/src/platform/packages/shared/kbn-workspaces/src/bootstrap.ts @@ -78,12 +78,12 @@ export async function bootstrap({ dir, log }: CheckoutAndBootstrapOptions) { await writeVersionFile(log, Path.join(dir, '.nvmrc'), currentNodeVersion, false); // set ignore-engines to true to prevent validation errors from other spawned processes - await exec(`yarn config set ignore-engines true`, { + await exec('yarn', ['config', 'set', 'ignore-engines', 'true'], { cwd: dir, log, }); - await exec(`yarn kbn bootstrap --force-install`, { + await exec('yarn', ['kbn', 'bootstrap', '--force-install'], { log, cwd: dir, env: { diff --git a/src/platform/packages/shared/kbn-workspaces/src/ensure_cloned_repo.ts b/src/platform/packages/shared/kbn-workspaces/src/ensure_cloned_repo.ts index ab1e2f47109e8..6a0dc4fd6efe0 100644 --- a/src/platform/packages/shared/kbn-workspaces/src/ensure_cloned_repo.ts +++ b/src/platform/packages/shared/kbn-workspaces/src/ensure_cloned_repo.ts @@ -28,7 +28,7 @@ export async function ensureClonedRepo(context: WorkspaceGlobalContext): Promise if (!gitDirExists) { log.info(`Cloning base repo from ${repoRoot} to ${baseCloneDir}`); - await exec(`git clone ${repoRoot} ${baseCloneDir}`, { + await exec('git', ['clone', repoRoot, baseCloneDir], { log, cwd: process.cwd(), }); @@ -37,7 +37,7 @@ export async function ensureClonedRepo(context: WorkspaceGlobalContext): Promise log.debug(`Base clone already present at ${baseCloneDir}; fetching updates`); - await exec('git fetch --all --prune', { + await exec('git', ['fetch', '--all', '--prune'], { log, cwd: baseCloneDir, }); diff --git a/src/platform/packages/shared/kbn-workspaces/src/ensure_worktree.ts b/src/platform/packages/shared/kbn-workspaces/src/ensure_worktree.ts index 664483158aca2..552311e38f8ef 100644 --- a/src/platform/packages/shared/kbn-workspaces/src/ensure_worktree.ts +++ b/src/platform/packages/shared/kbn-workspaces/src/ensure_worktree.ts @@ -34,7 +34,7 @@ export async function ensureWorktree( log.info(`Creating worktree at ${path} for ref ${ref}`); - await exec(`git worktree add --detach ../${path} ${ref}`, { + await exec('git', ['worktree', 'add', '--detach', `../${path}`, ref], { log, cwd: baseCloneDir, }); diff --git a/src/platform/packages/shared/kbn-workspaces/src/exec.ts b/src/platform/packages/shared/kbn-workspaces/src/exec.ts index 935a41dbf664f..487cc2e771363 100644 --- a/src/platform/packages/shared/kbn-workspaces/src/exec.ts +++ b/src/platform/packages/shared/kbn-workspaces/src/exec.ts @@ -46,8 +46,7 @@ export async function exec( if (args.length === 2) { // A single command string is passed, which may contain shell-specific syntax like `&&` or `||`. // To ensure these are interpreted correctly, we must use a shell. - child = execa.command(args[0], { ...execaOpts, shell: true }); - + child = execa('sh', ['-c', args[0]], { ...execaOpts }); log.debug(`Running command with shell: ${args[0]} in ${cwd}`); } else { // A file and arguments array are passed, so we can execute it directly without a shell. diff --git a/src/setup_node_env/exit_on_warning.js b/src/setup_node_env/exit_on_warning.js index 40d78071f9a4a..6144ac89982db 100644 --- a/src/setup_node_env/exit_on_warning.js +++ b/src/setup_node_env/exit_on_warning.js @@ -107,6 +107,11 @@ var IGNORE_WARNINGS = [ messageContains: 'Keys with collection values will be stringified due to JS Object restrictions', }, + // url.parse deprecated. migrate to WHATWG URL API. + { + name: 'DeprecationWarning', + code: 'DEP0169', + }, ]; if (process.noProcessWarnings !== true) { diff --git a/x-pack/platform/plugins/shared/agent_builder/server/services/plugins/utils/sourcing/save_uploaded_file.test.ts b/x-pack/platform/plugins/shared/agent_builder/server/services/plugins/utils/sourcing/save_uploaded_file.test.ts index 972c076a899ea..262ed11dc0020 100644 --- a/x-pack/platform/plugins/shared/agent_builder/server/services/plugins/utils/sourcing/save_uploaded_file.test.ts +++ b/x-pack/platform/plugins/shared/agent_builder/server/services/plugins/utils/sourcing/save_uploaded_file.test.ts @@ -72,11 +72,15 @@ describe('saveUploadedFile', () => { it('deletes the temp file when the pipeline fails', async () => { const writeStream = new PassThrough(); - writeStream.destroy(new Error('write error')); mockCreateWriteStream.mockReturnValue(writeStream); const input = Readable.from(Buffer.from('zip content')); + // Destroy the write stream on next tick so pipeline has time to attach error handlers + process.nextTick(() => { + writeStream.destroy(new Error('write error')); + }); + await expect(saveUploadedFile(input)).rejects.toThrow(); expect(mockDeleteFile).toHaveBeenCalledWith('tmp/test-uuid-1234.zip', { diff --git a/x-pack/solutions/observability/packages/kbn-evals-suite-obs-ai-assistant/src/clients/chat/obs_ai_assistant_client.ts b/x-pack/solutions/observability/packages/kbn-evals-suite-obs-ai-assistant/src/clients/chat/obs_ai_assistant_client.ts index e8749bedd60de..159d7cb05eefb 100644 --- a/x-pack/solutions/observability/packages/kbn-evals-suite-obs-ai-assistant/src/clients/chat/obs_ai_assistant_client.ts +++ b/x-pack/solutions/observability/packages/kbn-evals-suite-obs-ai-assistant/src/clients/chat/obs_ai_assistant_client.ts @@ -168,22 +168,50 @@ export class ObservabilityAIAssistantEvaluationChatClient implements ChatClient const decoder = new TextDecoder(); - // @ts-expect-error upgrade typescript v5.9.3 - const iterator: NodeJS.AsyncIterator = { - async next() { - const { done, value } = await reader.read(); - - if (done) { - const tail = decoder.decode(undefined, { stream: false }); - return { value: tail || undefined, done: true }; + let emittedTail = false; + const iterator: NodeJS.AsyncIterator = { + async next(): Promise> { + if (emittedTail) { + return { + done: true, + value: undefined, + }; } - const text = decoder.decode(value, { stream: true }); - return { value: text, done: false }; + while (true) { + const { done, value } = await reader.read(); + + if (done) { + const tail = decoder.decode(undefined, { stream: false }); + if (tail) { + emittedTail = true; + return { + done: false, + value: tail, + }; + } + + return { + done: true, + value: undefined, + }; + } + + const text = decoder.decode(value, { stream: true }); + if (text) { + return { + done: false, + value: text, + }; + } + } }, [Symbol.asyncIterator]() { return this; }, + async [Symbol.asyncDispose]() { + await reader.cancel(); + }, }; return streamIntoObservable(iterator); diff --git a/x-pack/solutions/security/plugins/kubernetes_security/public/components/count_widget/helpers.test.ts b/x-pack/solutions/security/plugins/kubernetes_security/public/components/count_widget/helpers.test.ts index f3741e38d7947..790a5cec30450 100644 --- a/x-pack/solutions/security/plugins/kubernetes_security/public/components/count_widget/helpers.test.ts +++ b/x-pack/solutions/security/plugins/kubernetes_security/public/components/count_widget/helpers.test.ts @@ -32,17 +32,17 @@ const RESULT_QUERY_POD = describe('Testing Helper functions', () => { it('Testing numberFormatter helper function', () => { expect(numberFormatter(TEST_DATA_ARRAY[0])).toBe('32'); - expect(numberFormatter(TEST_DATA_ARRAY[1])).toBe('2K'); - expect(numberFormatter(TEST_DATA_ARRAY[2])).toBe('999K'); - expect(numberFormatter(TEST_DATA_ARRAY[3])).toBe('1.3M'); - expect(numberFormatter(TEST_DATA_ARRAY[4])).toBe('999M'); - expect(numberFormatter(TEST_DATA_ARRAY[5])).toBe('999B'); - expect(numberFormatter(TEST_DATA_ARRAY[6])).toBe('1.2T'); + expect(numberFormatter(TEST_DATA_ARRAY[1])).toBe('2k'); + expect(numberFormatter(TEST_DATA_ARRAY[2])).toBe('999k'); + expect(numberFormatter(TEST_DATA_ARRAY[3])).toBe('1.3m'); + expect(numberFormatter(TEST_DATA_ARRAY[4])).toBe('999m'); + expect(numberFormatter(TEST_DATA_ARRAY[5])).toBe('999bn'); + expect(numberFormatter(TEST_DATA_ARRAY[6])).toBe('1.2tn'); expect(numberFormatter(TEST_DATA_ARRAY[7])).toBe('NaN'); expect(numberFormatter(TEST_DATA_ARRAY[8])).toBe('NaN'); expect(numberFormatter(TEST_DATA_ARRAY[9])).toBe('NaN'); expect(numberFormatter(TEST_DATA_ARRAY[10])).toBe('NaN'); - expect(numberFormatter(TEST_DATA_ARRAY[11])).toBe('999T'); + expect(numberFormatter(TEST_DATA_ARRAY[11])).toBe('999tn'); }); it('Testing addResourceTypeToFilterQuery helper function', () => { diff --git a/x-pack/solutions/security/plugins/kubernetes_security/public/components/count_widget/index.test.tsx b/x-pack/solutions/security/plugins/kubernetes_security/public/components/count_widget/index.test.tsx index 7643814c7a441..66449f68442f2 100644 --- a/x-pack/solutions/security/plugins/kubernetes_security/public/components/count_widget/index.test.tsx +++ b/x-pack/solutions/security/plugins/kubernetes_security/public/components/count_widget/index.test.tsx @@ -89,7 +89,7 @@ describe('CountWidget component', () => { render(); expect(renderResult.getByText(TITLE)).toBeVisible(); - expect(renderResult.getByText('5K')).toBeVisible(); + expect(renderResult.getByText('5k')).toBeVisible(); }); }); @@ -102,7 +102,7 @@ describe('CountWidget component', () => { render(); expect(renderResult.getByText(TITLE)).toBeVisible(); - expect(renderResult.getByText('1.2M')).toBeVisible(); + expect(renderResult.getByText('1.2m')).toBeVisible(); }); }); @@ -115,7 +115,7 @@ describe('CountWidget component', () => { render(); expect(renderResult.getByText(TITLE)).toBeVisible(); - expect(renderResult.getByText('999K')).toBeVisible(); + expect(renderResult.getByText('999k')).toBeVisible(); }); }); diff --git a/yarn.lock b/yarn.lock index 19682dff65678..9528c50fe50ef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14886,19 +14886,12 @@ dependencies: "@types/node" "*" -"@types/node@*", "@types/node@14 || 16 || 17", "@types/node@22.19.1", "@types/node@>=13.7.0", "@types/node@>=18.0.0", "@types/node@^18.0.0", "@types/node@^18.11.18", "@types/node@^24.0.3": - version "22.19.1" - resolved "https://registry.yarnpkg.com/@types/node/-/node-22.19.1.tgz#1188f1ddc9f46b4cc3aec76749050b4e1f459b7b" - integrity sha512-LCCV0HdSZZZb34qifBsyWlUmok6W7ouER+oQIGBScS8EsZsQbrtFTUrDX4hOl+CS6p7cnNC4td+qrSVGSCTUfQ== +"@types/node@*", "@types/node@14 || 16 || 17", "@types/node@24.10.13", "@types/node@>=13.7.0", "@types/node@>=18.0.0", "@types/node@^18.0.0", "@types/node@^18.11.18", "@types/node@^24.0.3": + version "24.10.13" + resolved "https://registry.yarnpkg.com/@types/node/-/node-24.10.13.tgz#2fac25c0e30f3848e19912c3b8791a28370e9e07" + integrity sha512-oH72nZRfDv9lADUBSo104Aq7gPHpQZc4BTx38r9xf9pg5LfP6EzSyH2n7qFmmxRQXh7YlUXODcYsg6PuTDSxGg== dependencies: - undici-types "~6.21.0" - -"@types/node@22.19.0": - version "22.19.0" - resolved "https://registry.yarnpkg.com/@types/node/-/node-22.19.0.tgz#849606ef3920850583a4e7ee0930987c35ad80be" - integrity sha512-xpr/lmLPQEj+TUnHmR+Ab91/glhJvsqcjB+yY0Ix9GO70H6Lb4FHH5GeqdOE5btAx7eIMwuHkp4H2MSkLcqWbA== - dependencies: - undici-types "~6.21.0" + undici-types "~7.16.0" "@types/nodemailer@7.0.6": version "7.0.6" @@ -35135,21 +35128,21 @@ unc-path-regex@^0.1.2: resolved "https://registry.yarnpkg.com/unc-path-regex/-/unc-path-regex-0.1.2.tgz#e73dd3d7b0d7c5ed86fbac6b0ae7d8c6a69d50fa" integrity sha1-5z3T17DXxe2G+6xrCufYxqadUPo= -undici-types@~6.21.0: - version "6.21.0" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.21.0.tgz#691d00af3909be93a7faa13be61b3a5b50ef12cb" - integrity sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ== +undici-types@~7.16.0: + version "7.16.0" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.16.0.tgz#ffccdff36aea4884cbfce9a750a0580224f58a46" + integrity sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw== -undici@6.23.0, undici@^6.21.1, undici@^6.21.2, undici@^6.23.0: +undici@7.24.4, undici@^7.19.1: + version "7.24.4" + resolved "https://registry.yarnpkg.com/undici/-/undici-7.24.4.tgz#873bce680d7c6354c941399fd4e8ea4563de4ea7" + integrity sha512-BM/JzwwaRXxrLdElV2Uo6cTLEjhSb3WXboncJamZ15NgUURmvlXvxa6xkwIOILIjPNo9i8ku136ZvWV0Uly8+w== + +undici@^6.21.1, undici@^6.21.2, undici@^6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/undici/-/undici-6.23.0.tgz#7953087744d9095a96f115de3140ca3828aff3a4" integrity sha512-VfQPToRA5FZs/qJxLIinmU59u0r7LXqoJkCzinq3ckNJp3vKEh7jTWN589YQ5+aoAC/TGRLyJLCPKcLQbM8r9g== -undici@^7.19.1: - version "7.22.0" - resolved "https://registry.yarnpkg.com/undici/-/undici-7.22.0.tgz#7a82590a5908e504a47d85c60b0f89ca14240e60" - integrity sha512-RqslV2Us5BrllB+JeiZnK4peryVTndy9Dnqq62S3yYRRTj0tFQCwEniUy2167skdGOy3vqRzEvl1Dm4sV2ReDg== - unherit@^1.0.4: version "1.1.0" resolved "https://registry.yarnpkg.com/unherit/-/unherit-1.1.0.tgz#6b9aaedfbf73df1756ad9e316dd981885840cd7d"