redis/node-redis · error · Error
vectorOutput is undefined
Error message
vectorOutput is undefined
What it means
Thrown by an explicit guard in the doctest's embedText() helper. The @xenova/transformers pipeline('feature-extraction', ...) call resolved to null/undefined for the input sentence, so vectorOutput.data cannot be read. transformers.js returns null when model loading, inference, or ONNX runtime setup fails internally and swallows the underlying cause.
Solutions
- Wrap the pipe() call in try/catch to surface the real upstream error (transformers.js hides it behind the null return).
- Verify network access to huggingface.co or pre-download the model into a local cache directory and point env.cacheDir at it.
- Pin @xenova/transformers to a version known to work with your Node runtime and the all-MiniLM-L6-v2 model.
- Confirm the model id is correct and reachable: test with transformers.js standalone before invoking the doctest.
Example fix
// before
let pipe = await pipeline('feature-extraction', modelName);
let vectorOutput = await pipe(sentence, { pooling: 'mean', normalize: true });
if (vectorOutput == null) throw new Error('vectorOutput is undefined');
// after
const pipe = await pipeline('feature-extraction', modelName);
let vectorOutput;
try {
vectorOutput = await pipe(sentence, { pooling: 'mean', normalize: true });
} catch (err) {
throw new Error('feature-extraction inference failed: ' + err.message, { cause: err });
}
if (vectorOutput == null || !('data' in vectorOutput)) {
throw new Error('vectorOutput is undefined (model load or inference returned nothing)');
} Defensive patterns
Strategy: try-catch
Validate before calling
import { pipeline, env } from '@xenova/transformers';
async function safePipeline(name) {
try {
const pipe = await pipeline('feature-extraction', name);
if (typeof pipe !== 'function') {
throw new Error('pipeline did not return a callable');
}
return pipe;
} catch (err) {
throw new Error(`transformers pipeline init failed for ${name}: ${err.message}`, { cause: err });
}
}
// call before the doctest runs
const pipe = await safePipeline('Xenova/all-MiniLM-L6-v2'); Type guard
function isTensor(v) {
return v != null && typeof v === 'object' && 'data' in v && typeof v.data.length === 'number';
} Try / catch
try {
vectorOutput = await pipe(sentence, { pooling: 'mean', normalize: true });
} catch (err) {
throw new Error('feature-extraction failed: ' + err.message, { cause: err });
}
if (!isTensor(vectorOutput)) throw new Error('vectorOutput is undefined'); Prevention
- Pre-warm and cache the pipeline once at process startup; reuse the instance.
- Pin @xenova/transformers and verify Node/ONNX runtime compatibility.
- Set env.cacheDir and pre-download the model so offline runs do not return null.
- Wrap pipe() in try/catch — transformers.js swallows inference errors into null returns.
When it happens
Trigger: Running doctests/query-combined.js and the await pipe(sentence, { pooling: 'mean', normalize: true }) call resolves to null/undefined. Happens when the model artifact fails to load, ONNX backend init fails, or inference throws and is caught upstream.
Common situations: HuggingFace model download blocked (offline/corporate proxy); @xenova/transformers version mismatch with the bundled ONNX runtime; Node version incompatibility; model name typo 'Xenova/all-MiniLM-L6-v2'; first-run fetch timeout; WASM threads disabled in the runtime.
Related errors
- All the root nodes are unavailable
- Couldn't connect to any sentinel node
- couldn't connect to any sentinels
- No endpoints found for database
- None of the sentinels are available
AI-assisted analysis of redis/node-redis@90fd0652bc (2026-08-11).
Data as JSON: /api/errors/6acb6ec303693a29.
Report an issue: GitHub.
Appendix: source
Thrown at doctests/query-combined.js:25
import { pipeline } from '@xenova/transformers';
function float32Buffer(arr) {
const floatArray = new Float32Array(arr);
const float32Buffer = Buffer.from(floatArray.buffer);
return float32Buffer;
}
async function embedText(sentence) {
let modelName = 'Xenova/all-MiniLM-L6-v2';
let pipe = await pipeline('feature-extraction', modelName);
let vectorOutput = await pipe(sentence, {
pooling: 'mean',
normalize: true,
});
if (vectorOutput == null) {
throw new Error('vectorOutput is undefined');
}
const embedding = Object.values(vectorOutput.data);
return embedding;
}
let vector_query = float32Buffer(await embedText('That is a very happy person'));
const client = createClient();
await client.connect().catch(console.error);
// create index
await client.ft.create('idx:bicycle', {
'$.description': {
type: SCHEMA_FIELD_TYPE.TEXT,
AS: 'description'
},View on GitHub (pinned to 90fd0652bc)