feat: Add adaptive timeouts and WASM memory error recovery for robust parsing
Implements file-size-based timeouts (base 10s + 10s per 100KB), more frequent worker recycling (250 files), and automatic retry logic for WASM memory corruption failures. Workers now crash immediately on memory errors to prevent cascading failures, with failed files automatically retried on fresh workers with clean heaps.
This commit is contained in:
@@ -33,6 +33,14 @@ parentPort!.on('message', async (msg: { type: string; id?: number; filePath?: st
|
||||
parentPort!.postMessage({ type: 'parse-result', id, result });
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
|
||||
// WASM memory errors leave the module in a corrupted state — all
|
||||
// subsequent parses would also fail (cascading failures). Crash the
|
||||
// worker so the main thread spawns a fresh one with a clean heap.
|
||||
if (message.includes('memory access out of bounds') || message.includes('out of memory')) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
parentPort!.postMessage({
|
||||
type: 'parse-result',
|
||||
id,
|
||||
|
||||
Reference in New Issue
Block a user