sourcegraph / sourcegraph/scip-typescript
[bug] `scip.scip.Index.deserializeBinary()` fails to deserialize ~2 GiB `index.scip` file
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 115
- Forks
- 42
- Avg merge
- 12d 22h
- Merged PRs (30d)
- 6
Description
To reproduce run the following TS script and see that it hangs after Deserializing index...
// NODE_OPTIONS='--max-old-space-size=40960' pnpm ts-node main.ts
import { createReadStream } from 'fs';
import * as scip from '@sourcegraph/scip-typescript/dist/src/scip';
async function readLargeFile(filePath: string): Promise<Buffer> {
return new Promise((resolve, reject) => {
const chunks: Buffer[] = [];
const stream = createReadStream(filePath);
stream.on('data', (chunk) => chunks.push(Buffer.from(chunk)));
stream.on('error', (error) => reject(error));
stream.on('end', () => resolve(Buffer.concat(chunks)));
});
}
async function main() {
try {
// Read the binary SCIP file using streams
console.log('Reading SCIP file...');
const buffer = await readLargeFile('index.scip');
console.log('File read complete. Size:', buffer.length, 'bytes');
// Deserialize the SCIP index
console.log('Deserializing index...');
const index = scip.scip.Index.deserializeBinary(buffer);
// Log some basic information about the index
console.log('\nSCIP Index Information:');
const metadata = index.getMetadata();
if (metadata) {
console.log('Project Root:', metadata.getProjectRoot());
const toolInfo = metadata.getToolInfo();
if (toolInfo) {
console.log('Tool Name:', toolInfo.getName());
console.log('Tool Version:', toolInfo.getVersion());
}
}
const documents = index.getDocumentsList();
console.log('\nDocuments:', documents.length);
// Show information about the first few documents
documents.slice(0, 5).forEach((doc, i) => {
console.log(`\nDocument ${i + 1}:`);
console.log('Path:', doc.getRelativePath());
console.log('Language:', scip.scip.Language[doc.getLanguage()]);
console.log('Occurrences:', doc.getOccurrencesList().length);
console.log('Symbols:', doc.getSymbolsList().length);
});
} catch (error) {
console.error('Error processing SCIP file:', error);
}
}
main();
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided TypeScript reproduction and the call to scip.scip.Index.deserializeBinary(buffer), using the large index.scip file to confirm where deserialization stops progressing. Read the generated SCIP deserialization entry point and inspect behavior with the roughly 2 GiB buffer. Done means the reproduction completes and the index metadata and document information can be read without hanging.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100