Skip to content

Commit 7319fe3

Browse files
committed
Adding timeouts
Signed-off-by: Denis Jannot <denis.jannot@solo.io>
1 parent 2b458e1 commit 7319fe3

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

content-processor.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1935,7 +1935,12 @@ export class ContentProcessor {
19351935
if (lang) {
19361936
try {
19371937
const codeChunker = await this.getCodeChunker(lang, sourceConfig.chunk_size);
1938-
chunks = await codeChunker.chunk(code);
1938+
chunks = await Promise.race([
1939+
codeChunker.chunk(code),
1940+
new Promise<never>((_, reject) =>
1941+
setTimeout(() => reject(new Error(`CodeChunker timed out after 30s for ${normalizedPath || url}`)), 30000)
1942+
)
1943+
]);
19391944
} catch (error) {
19401945
logger.warn(`CodeChunker failed for ${normalizedPath || url}, falling back to token chunking:`, error);
19411946
const chunker = await this.getTokenChunker(sourceConfig.chunk_size);

doc2vec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,7 +1726,7 @@ export class Doc2Vec {
17261726
const response = await this.openai.embeddings.create({
17271727
model: this.embeddingModel,
17281728
input: safeTexts,
1729-
});
1729+
}, { timeout: 60000 });
17301730
logger.debug(`Successfully created ${response.data.length} embeddings`);
17311731
return response.data.map(d => d.embedding);
17321732
} catch (error) {
@@ -1743,5 +1743,7 @@ if (require.main === module) {
17431743
process.exit(1);
17441744
}
17451745
const doc2Vec = new Doc2Vec(configPath);
1746-
doc2Vec.run().catch(console.error);
1746+
doc2Vec.run()
1747+
.then(() => process.exit(0))
1748+
.catch((err) => { console.error(err); process.exit(1); });
17471749
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "doc2vec",
3-
"version": "2.9.0",
3+
"version": "2.9.1",
44
"type": "commonjs",
55
"description": "",
66
"main": "dist/doc2vec.js",

0 commit comments

Comments
 (0)