mirror of
https://github.com/n8n-io/n8n.git
synced 2026-09-21 04:37:50 +08:00
fix(workflow-sdk): Use worker-specific temp dir to prevent flaky schema validation tests
Multiple Jest workers running validation tests in parallel all shared the same hardcoded temp dir (os.tmpdir()/n8n-schema-tests). This caused a race condition where one worker would delete and regenerate schemas while another was reading them, causing loadSchema() to return null and INVALID_PARAMETER warnings to not be generated. Fix by suffixing the temp dir with JEST_WORKER_ID so each worker has its own isolated schema directory. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
255c4049eb
commit
022526d372
@@ -14,7 +14,11 @@ import * as path from 'path';
|
||||
import { setSchemaBaseDirs, getSchemaBaseDirs } from './schema-validator';
|
||||
import { generateNodeDefinitions } from '../generate-types/generate-node-defs-cli';
|
||||
|
||||
const SCHEMA_TEST_DIR = path.join(os.tmpdir(), 'n8n-schema-tests');
|
||||
// Use a worker-specific directory to prevent race conditions when multiple Jest
|
||||
// workers run schema-using tests in parallel (they would otherwise concurrently
|
||||
// delete and regenerate schemas into the same shared temp directory).
|
||||
const WORKER_ID = process.env.JEST_WORKER_ID ?? '0';
|
||||
const SCHEMA_TEST_DIR = path.join(os.tmpdir(), `n8n-schema-tests-${WORKER_ID}`);
|
||||
const STAMP_FILE = path.join(SCHEMA_TEST_DIR, '.generator-hash');
|
||||
|
||||
let originalBaseDirs: string[] | undefined;
|
||||
|
||||
Reference in New Issue
Block a user