mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-07 08:26:11 +00:00
refactor(parse): move worker language guard helper and clarify warning
Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/1417a00f-d72b-4659-8c8e-e0c8a1cbfa4c
This commit is contained in:
parent
676f91ebf5
commit
f2cbf27219
3 changed files with 16 additions and 18 deletions
|
|
@ -45,11 +45,7 @@ import {
|
|||
} from '../heritage-processor.js';
|
||||
import { createResolutionContext } from '../model/resolution-context.js';
|
||||
import { ASTCache, createASTCache } from '../ast-cache.js';
|
||||
import {
|
||||
type PipelineProgress,
|
||||
getLanguageFromFilename,
|
||||
SupportedLanguages,
|
||||
} from 'gitnexus-shared';
|
||||
import { type PipelineProgress, getLanguageFromFilename } from 'gitnexus-shared';
|
||||
import { readFileContents } from '../filesystem-walker.js';
|
||||
import { isLanguageAvailable } from '../../tree-sitter/parser-loader.js';
|
||||
import { createWorkerPool } from '../workers/worker-pool.js';
|
||||
|
|
@ -75,6 +71,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
|
|||
import { isDev } from '../utils/env.js';
|
||||
import { synthesizeWildcardImportBindings, needsSynthesis } from './wildcard-synthesis.js';
|
||||
import { extractORMQueriesInline } from './orm-extraction.js';
|
||||
import { hasWorkerUnsafeLanguageMix } from '../workers/worker-language-guard.js';
|
||||
|
||||
import { logger } from '../../logger.js';
|
||||
// ── Constants ──────────────────────────────────────────────────────────────
|
||||
|
|
@ -100,17 +97,6 @@ const CHUNK_BYTE_BUDGET = (() => {
|
|||
type ScannedFile = { path: string; size: number };
|
||||
type ProgressFn = (progress: PipelineProgress) => void;
|
||||
|
||||
const WORKER_UNSAFE_LANGUAGES = new Set<SupportedLanguages>([
|
||||
SupportedLanguages.C,
|
||||
SupportedLanguages.CPlusPlus,
|
||||
]);
|
||||
|
||||
export const hasWorkerUnsafeLanguageMix = (files: readonly ScannedFile[]): boolean =>
|
||||
files.some((f) => {
|
||||
const language = getLanguageFromFilename(f.path);
|
||||
return language !== null && WORKER_UNSAFE_LANGUAGES.has(language);
|
||||
});
|
||||
|
||||
/**
|
||||
* Chunked parse + resolve loop.
|
||||
*
|
||||
|
|
@ -239,7 +225,7 @@ export async function runChunkedParseAndResolve(
|
|||
process.env.GITNEXUS_ALLOW_CPP_WORKERS !== '1' && hasWorkerUnsafeLanguageMix(parseableScanned);
|
||||
if (disableWorkersForNativeLanguages) {
|
||||
logger.warn(
|
||||
'C/C++ files detected — using sequential parser path to avoid known worker-thread native crashes (e.g. `Napi::Error`). Set GITNEXUS_ALLOW_CPP_WORKERS=1 to force workers.',
|
||||
'C/C++ files detected — using sequential parser path to avoid known worker-thread native binding errors (e.g. `Napi::Error`). Set GITNEXUS_ALLOW_CPP_WORKERS=1 to force workers.',
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
12
gitnexus/src/core/ingestion/workers/worker-language-guard.ts
Normal file
12
gitnexus/src/core/ingestion/workers/worker-language-guard.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { getLanguageFromFilename, SupportedLanguages } from 'gitnexus-shared';
|
||||
|
||||
const WORKER_UNSAFE_LANGUAGES = new Set<SupportedLanguages>([
|
||||
SupportedLanguages.C,
|
||||
SupportedLanguages.CPlusPlus,
|
||||
]);
|
||||
|
||||
export const hasWorkerUnsafeLanguageMix = (files: ReadonlyArray<{ path: string }>): boolean =>
|
||||
files.some((f) => {
|
||||
const language = getLanguageFromFilename(f.path);
|
||||
return language !== null && WORKER_UNSAFE_LANGUAGES.has(language);
|
||||
});
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { hasWorkerUnsafeLanguageMix } from '../../src/core/ingestion/pipeline-phases/parse-impl.js';
|
||||
import { hasWorkerUnsafeLanguageMix } from '../../src/core/ingestion/workers/worker-language-guard.js';
|
||||
|
||||
describe('hasWorkerUnsafeLanguageMix', () => {
|
||||
it('returns false for non-C/C++ inputs', () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue