Просмотр исходного кода

Merge pull request #8651 from overleaf/em-transient-warnings

Stop on first error: filter out transient warnings

GitOrigin-RevId: ec17a24e05ec28106fdc11f3d3a9e243ae191547
Eric Mc Sween 4 лет назад
Родитель
Сommit
cc9b490ef6
1 измененных файлов с 12 добавлено и 1 удалено
  1. 12 1
      services/web/frontend/js/features/pdf-preview/util/output-files.js

+ 12 - 1
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 BibLogParser from '../../../ide/log-parser/bib-log-parser'
 import { v4 as uuid } from 'uuid'
 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)
 const searchParams = new URLSearchParams(window.location.search)
 
 
 export function handleOutputFiles(outputFiles, projectId, data) {
 export function handleOutputFiles(outputFiles, projectId, data) {
@@ -79,7 +81,7 @@ export const handleLogFiles = async (outputFiles, data, signal) => {
 
 
       result.log = await response.text()
       result.log = await response.text()
 
 
-      const { errors, warnings, typesetting } = HumanReadableLogs.parse(
+      let { errors, warnings, typesetting } = HumanReadableLogs.parse(
         result.log,
         result.log,
         {
         {
           ignoreDuplicates: true,
           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 })
       accumulateResults({ errors, warnings, typesetting })
     } catch (e) {
     } catch (e) {
       console.warn(e) // ignore failure to fetch/parse the log file, but log a warning
       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
   return path
 }
 }
+
+function isTransientWarning(warning) {
+  return TRANSIENT_WARNING_REGEX.test(warning.message)
+}