cube-js/cube · error
Stream init error
Error message
Stream init error
What it means
getFileStream prepares a temp file and writer for streaming table data. If the async initialization did not produce a currentFileStream (e.g. the temp-file creation promise failed silently or pipeline setup threw before assignment), the driver throws 'Stream init error'.
Source
Thrown at packages/cubejs-cubestore-driver/src/CubeStoreDriver.ts:403
const fileName = `${table}-${fileCounter++}.csv.gz`;
filePromises.push(fetch(`${baseUrl.replace(/^ws/, 'http')}/upload-temp-file?name=${fileName}`, {
method: 'POST',
body: createReadStream(tempFile),
}).then(async res => {
if (res.status !== 200) {
const error = await res.json();
throw new Error(`Error during upload of ${fileName} create table: ${createTableSqlWithoutLocation}: ${error.error}`);
}
return fileName;
}));
resolve(null);
});
currentFileStream = { stream: writer, tempFile };
}));
}
if (!currentFileStream) {
throw new Error('Stream init error');
}
return currentFileStream;
};
let rowCount = 0;
const endStream = (chunk, encoding, callback) => {
const { stream } = getFileStream();
currentFileStream = null;
rowCount = 0;
if (chunk) {
stream.end(chunk, encoding, callback);
} else {
stream.end(callback);
}
};
const { batchingRowSplitCount } = this.config;View on GitHub (pinned to 7d981676b3)
Solutions
- Check temp directory writability and free disk space (TMPDIR / /tmp).
- Inspect earlier async errors swallowed by the pipeline promise (add logging).
- Verify process file-descriptor limits.
- Retry the pre-aggregation build after fixing the environment.
Defensive patterns
Strategy: validation
Validate before calling
import { accessSync, constants } from 'fs';
const tmpDir = process.env.TMPDIR || '/tmp';
accessSync(tmpDir, constants.W_OK); // throws early if temp dir is not writable Try / catch
try {
await driver.uploadTable(table, columns, tableData);
} catch (e) {
if (e.message === 'Stream init error') {
console.error('Temp file/stream init failed: check TMPDIR writability and disk space');
}
throw e;
} Prevention
- Ensure the build process has a writable temp directory with free space.
- Avoid low file-descriptor limits (ulimit -n) in build containers.
- Clean stale temp files regularly on build hosts.
- Check for swallowed errors in stream setup by enabling driver debug logs.
When it happens
Trigger: Temp file creation (tmpFile creation) or writer setup inside the promise chain rejects/resolves without setting currentFileStream, so the check `if (!currentFileStream)` fires.
Common situations: No writable temp directory (TMPDIR unwritable/full); permission errors creating temp files; OS-level file limits; Cube Store connection established after data already flowed.
Related errors
- Unable to import (as stream) in Cube Store: empty columns. M
- Older version of orchestrator is being used with newer versi
- Something wrong with downloading Cube Store before running i
- Unable to find package.json file in current working director
- options.stream must be a function
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/c8fb837d350abb6d.
Report an issue: GitHub.