From cc9b490ef66aada33bec1bde5ab651c714dbfaea Mon Sep 17 00:00:00 2001 From: Eric Mc Sween Date: Mon, 4 Jul 2022 08:25:24 -0400 Subject: [PATCH] Merge pull request #8651 from overleaf/em-transient-warnings Stop on first error: filter out transient warnings GitOrigin-RevId: ec17a24e05ec28106fdc11f3d3a9e243ae191547 --- .../js/features/pdf-preview/util/output-files.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/services/web/frontend/js/features/pdf-preview/util/output-files.js b/services/web/frontend/js/features/pdf-preview/util/output-files.js index 3e214f2465..7a064fd43c 100644 --- a/services/web/frontend/js/features/pdf-preview/util/output-files.js +++ b/services/web/frontend/js/features/pdf-preview/util/output-files.js @@ -3,6 +3,8 @@ import HumanReadableLogs from '../../../ide/human-readable-logs/HumanReadableLog import BibLogParser from '../../../ide/log-parser/bib-log-parser' import { v4 as uuid } from 'uuid' +// Warnings that may disappear after a second LaTeX pass +const TRANSIENT_WARNING_REGEX = /^(Reference|Citation).+undefined on input line/ const searchParams = new URLSearchParams(window.location.search) export function handleOutputFiles(outputFiles, projectId, data) { @@ -79,7 +81,7 @@ export const handleLogFiles = async (outputFiles, data, signal) => { result.log = await response.text() - const { errors, warnings, typesetting } = HumanReadableLogs.parse( + let { errors, warnings, typesetting } = HumanReadableLogs.parse( result.log, { ignoreDuplicates: true, @@ -88,6 +90,11 @@ export const handleLogFiles = async (outputFiles, data, signal) => { } ) + if (data.status === 'stopped-on-first-error') { + // Hide warnings that could disappear after a second pass + warnings = warnings.filter(warning => !isTransientWarning(warning)) + } + accumulateResults({ errors, warnings, typesetting }) } catch (e) { console.warn(e) // ignore failure to fetch/parse the log file, but log a warning @@ -179,3 +186,7 @@ function normalizeFilePath(path, rootDocDirname) { return path } + +function isTransientWarning(warning) { + return TRANSIENT_WARNING_REGEX.test(warning.message) +}