From c9a511d56bd205b522c7955b021db0ac25afdc71 Mon Sep 17 00:00:00 2001 From: Eric Fritz Date: Tue, 19 May 2020 13:30:04 -0500 Subject: [PATCH] Raise buffer size when reading LSIF header. --- cmd/src/lsif_upload.go | 2 +- internal/codeintel/indexer_name.go | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/src/lsif_upload.go b/cmd/src/lsif_upload.go index e1bdb0328c..7e3ccaf2af 100644 --- a/cmd/src/lsif_upload.go +++ b/cmd/src/lsif_upload.go @@ -31,7 +31,7 @@ Examples: Upload an LSIF dump when the LSIF indexer does not not declare a tool name. - $ src lsif upload -indexerName=lsif-elixir + $ src lsif upload -indexer=lsif-elixir ` var flags struct { diff --git a/internal/codeintel/indexer_name.go b/internal/codeintel/indexer_name.go index 2d2859f2fe..212f368aad 100644 --- a/internal/codeintel/indexer_name.go +++ b/internal/codeintel/indexer_name.go @@ -16,6 +16,14 @@ type toolInfo struct { Name string `json:"name"` } +// MaxBufferSize is the maximum size of the metaData line in the dump. This should be large enough +// to be able to read the output of lsif-tsc for most cases, which will contain all glob-expanded +// file names in the indexing of JavaScript projects. +// +// Data point: lodash's metaData vertex constructed by the args `*.js test/*.js --AllowJs --checkJs` +// is 10639 characters long. +const MaxBufferSize = 128 * 1024 + // ErrMetadataExceedsBuffer occurs when the first line of an LSIF index is too long to read. var ErrMetadataExceedsBuffer = errors.New("metaData vertex exceeds buffer") @@ -26,7 +34,7 @@ var ErrInvalidMetaDataVertex = errors.New("invalid metaData vertex") // This function reads only the first line of the file, where the metadata vertex is // assumed to be in all valid dumps. func ReadIndexerName(r io.Reader) (string, error) { - line, isPrefix, err := bufio.NewReader(r).ReadLine() + line, isPrefix, err := bufio.NewReaderSize(r, MaxBufferSize).ReadLine() if err != nil { return "", err }