[bug] `scip.scip.Index.deserializeBinary()` fails to deserialize ~2 GiB `index.scip` file

Open
#407 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
32/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
typescript
Domain
tooling

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.

Description

graph/scip-typescript team/graph

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();
Dominant language
TypeScript
Stars
115
Forks
42
Avg merge
12d 22h
Merged PRs (30d)
6

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sourcegraph/scip-typescript

All issues in sourcegraph/scip-typescript

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.