Skip to content

LSIF: Prevent worker from crashing on missing input dump file

Administrator requested to merge lsif-fix-locked-worker into master

Created by: efritz

This one took a LONG time to track down.

Current organization: createReadStream returns a Readable stream which is then passed to splitLines through two promise boundaries (convertLsif and importLsif). This means that the creation of the read stream and the use of it is NOT within the same tick.

Current behavior: createReadStream synchronously returns a Readable stream, which is also an event emitter. On IO error of opening the file, an error is emitted. Since this happened on a tick that occurs before splitLines has started, no error is caught and it crashes the process.

New organization: Instead of passing the readable down into splitLines, we pass the filename and the input functions are responsible for creating the stream. This allows us to bind to the error event in the same tick as we create it so that we can inject the error into the async iterable produced by splitLines.

Current behavior: On IO error opening the file (specifically ENOENT), we throw from splitLines. This causes the job to fail (rightfully) instead of the the entire process to crash (which is amateur hour).

Merge request reports

Loading