CompileManager.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. const fsPromises = require('node:fs/promises')
  2. const os = require('node:os')
  3. const Path = require('node:path')
  4. const { callbackify } = require('node:util')
  5. const Settings = require('@overleaf/settings')
  6. const logger = require('@overleaf/logger')
  7. const OError = require('@overleaf/o-error')
  8. const ResourceWriter = require('./ResourceWriter')
  9. const LatexRunner = require('./LatexRunner')
  10. const OutputFileFinder = require('./OutputFileFinder')
  11. const OutputCacheManager = require('./OutputCacheManager')
  12. const Metrics = require('./Metrics')
  13. const DraftModeManager = require('./DraftModeManager')
  14. const TikzManager = require('./TikzManager')
  15. const LockManager = require('./LockManager')
  16. const Errors = require('./Errors')
  17. const CommandRunner = require('./CommandRunner')
  18. const { emitPdfStats } = require('./ContentCacheMetrics')
  19. const SynctexOutputParser = require('./SynctexOutputParser')
  20. const {
  21. downloadLatestCompileCache,
  22. downloadOutputDotSynctexFromCompileCache,
  23. } = require('./CLSICacheHandler')
  24. const COMPILE_TIME_BUCKETS = [
  25. // NOTE: These buckets are locked in per metric name.
  26. // If you want to change them, you will need to rename metrics.
  27. 0, 1, 2, 3, 4, 6, 8, 11, 15, 22, 31, 43, 61, 86, 121, 170, 240,
  28. ].map(seconds => seconds * 1000)
  29. function getCompileName(projectId, userId) {
  30. if (userId != null) {
  31. return `${projectId}-${userId}`
  32. } else {
  33. return projectId
  34. }
  35. }
  36. function getCompileDir(projectId, userId) {
  37. return Path.join(Settings.path.compilesDir, getCompileName(projectId, userId))
  38. }
  39. function getOutputDir(projectId, userId) {
  40. return Path.join(Settings.path.outputDir, getCompileName(projectId, userId))
  41. }
  42. async function doCompileWithLock(request) {
  43. const compileDir = getCompileDir(request.project_id, request.user_id)
  44. request.isInitialCompile =
  45. (await fsPromises.mkdir(compileDir, { recursive: true })) === compileDir
  46. // prevent simultaneous compiles
  47. const lock = LockManager.acquire(compileDir)
  48. try {
  49. return await doCompile(request)
  50. } finally {
  51. lock.release()
  52. }
  53. }
  54. async function doCompile(request) {
  55. const { project_id: projectId, user_id: userId } = request
  56. const compileDir = getCompileDir(request.project_id, request.user_id)
  57. const stats = {}
  58. const timings = {}
  59. const timerE2E = new Metrics.Timer(
  60. 'compile-e2e-v2',
  61. 1,
  62. request.metricsOpts,
  63. COMPILE_TIME_BUCKETS
  64. )
  65. if (request.isInitialCompile) {
  66. stats.isInitialCompile = 1
  67. request.metricsOpts.compile = 'initial'
  68. if (request.compileFromClsiCache) {
  69. try {
  70. if (await downloadLatestCompileCache(projectId, userId, compileDir)) {
  71. stats.restoredClsiCache = 1
  72. request.metricsOpts.compile = 'from-clsi-cache'
  73. }
  74. } catch (err) {
  75. logger.warn(
  76. { err, projectId, userId },
  77. 'failed to populate compile dir from cache'
  78. )
  79. }
  80. }
  81. } else {
  82. request.metricsOpts.compile = 'recompile'
  83. }
  84. const writeToDiskTimer = new Metrics.Timer(
  85. 'write-to-disk',
  86. 1,
  87. request.metricsOpts
  88. )
  89. logger.debug(
  90. { projectId: request.project_id, userId: request.user_id },
  91. 'syncing resources to disk'
  92. )
  93. let resourceList
  94. try {
  95. // NOTE: resourceList is insecure, it should only be used to exclude files from the output list
  96. resourceList = await ResourceWriter.promises.syncResourcesToDisk(
  97. request,
  98. compileDir
  99. )
  100. } catch (error) {
  101. if (error instanceof Errors.FilesOutOfSyncError) {
  102. OError.tag(error, 'files out of sync, please retry', {
  103. projectId: request.project_id,
  104. userId: request.user_id,
  105. })
  106. } else {
  107. OError.tag(error, 'error writing resources to disk', {
  108. projectId: request.project_id,
  109. userId: request.user_id,
  110. })
  111. }
  112. throw error
  113. }
  114. logger.debug(
  115. {
  116. projectId: request.project_id,
  117. userId: request.user_id,
  118. timeTaken: Date.now() - writeToDiskTimer.start,
  119. },
  120. 'written files to disk'
  121. )
  122. timings.sync = writeToDiskTimer.done()
  123. // set up environment variables for chktex
  124. const env = {
  125. OVERLEAF_PROJECT_ID: request.project_id,
  126. }
  127. if (Settings.texliveOpenoutAny && Settings.texliveOpenoutAny !== '') {
  128. // override default texlive openout_any environment variable
  129. env.openout_any = Settings.texliveOpenoutAny
  130. }
  131. if (Settings.texliveMaxPrintLine && Settings.texliveMaxPrintLine !== '') {
  132. // override default texlive max_print_line environment variable
  133. env.max_print_line = Settings.texliveMaxPrintLine
  134. }
  135. // only run chktex on LaTeX files (not knitr .Rtex files or any others)
  136. const isLaTeXFile = request.rootResourcePath?.match(/\.tex$/i)
  137. if (request.check != null && isLaTeXFile) {
  138. env.CHKTEX_OPTIONS = '-nall -e9 -e10 -w15 -w16'
  139. env.CHKTEX_ULIMIT_OPTIONS = '-t 5 -v 64000'
  140. if (request.check === 'error') {
  141. env.CHKTEX_EXIT_ON_ERROR = 1
  142. }
  143. if (request.check === 'validate') {
  144. env.CHKTEX_VALIDATE = 1
  145. }
  146. }
  147. // apply a series of file modifications/creations for draft mode and tikz
  148. if (request.draft) {
  149. await DraftModeManager.promises.injectDraftMode(
  150. Path.join(compileDir, request.rootResourcePath)
  151. )
  152. }
  153. const needsMainFile = await TikzManager.promises.checkMainFile(
  154. compileDir,
  155. request.rootResourcePath,
  156. resourceList
  157. )
  158. if (needsMainFile) {
  159. await TikzManager.promises.injectOutputFile(
  160. compileDir,
  161. request.rootResourcePath
  162. )
  163. }
  164. const compileTimer = new Metrics.Timer('run-compile', 1, request.metricsOpts)
  165. // find the image tag to log it as a metric, e.g. 2015.1 (convert . to - for graphite)
  166. let tag = 'default'
  167. if (request.imageName != null) {
  168. const match = request.imageName.match(/:(.*)/)
  169. if (match != null) {
  170. tag = match[1].replace(/\./g, '-')
  171. }
  172. }
  173. // exclude smoke test
  174. if (!request.project_id.match(/^[0-9a-f]{24}$/)) {
  175. tag = 'other'
  176. }
  177. Metrics.inc('compiles', 1, request.metricsOpts)
  178. Metrics.inc(`compiles-with-image.${tag}`, 1, request.metricsOpts)
  179. const compileName = getCompileName(request.project_id, request.user_id)
  180. try {
  181. await LatexRunner.promises.runLatex(compileName, {
  182. directory: compileDir,
  183. mainFile: request.rootResourcePath,
  184. compiler: request.compiler,
  185. timeout: request.timeout,
  186. image: request.imageName,
  187. flags: request.flags,
  188. environment: env,
  189. compileGroup: request.compileGroup,
  190. stopOnFirstError: request.stopOnFirstError,
  191. stats,
  192. timings,
  193. })
  194. // We use errors to return the validation state. It would be nice to use a
  195. // more appropriate mechanism.
  196. if (request.check === 'validate') {
  197. const validationError = new Error('validation')
  198. validationError.validate = 'pass'
  199. throw validationError
  200. }
  201. } catch (originalError) {
  202. let error = originalError
  203. // request was for validation only
  204. if (request.check === 'validate' && !error.validate) {
  205. error = new Error('validation')
  206. error.validate = originalError.code ? 'fail' : 'pass'
  207. }
  208. // request was for compile, and failed on validation
  209. if (request.check === 'error' && originalError.message === 'exited') {
  210. error = new Error('compilation')
  211. error.validate = 'fail'
  212. }
  213. // record timeout errors as a separate counter, success is recorded later
  214. if (error.timedout) {
  215. Metrics.inc('compiles-timeout', 1, request.metricsOpts)
  216. }
  217. const { outputFiles, allEntries, buildId } = await _saveOutputFiles({
  218. request,
  219. compileDir,
  220. resourceList,
  221. stats,
  222. timings,
  223. })
  224. error.outputFiles = outputFiles // return output files so user can check logs
  225. error.buildId = buildId
  226. // Clear project if this compile was abruptly terminated
  227. if (error.terminated || error.timedout) {
  228. await clearProjectWithListing(
  229. request.project_id,
  230. request.user_id,
  231. allEntries
  232. )
  233. }
  234. throw error
  235. }
  236. // compile completed normally
  237. Metrics.inc('compiles-succeeded', 1, request.metricsOpts)
  238. for (const metricKey in stats) {
  239. const metricValue = stats[metricKey]
  240. Metrics.count(metricKey, metricValue, 1, request.metricsOpts)
  241. }
  242. for (const metricKey in timings) {
  243. const metricValue = timings[metricKey]
  244. Metrics.timing(metricKey, metricValue, 1, request.metricsOpts)
  245. }
  246. const loadavg = typeof os.loadavg === 'function' ? os.loadavg() : undefined
  247. if (loadavg != null) {
  248. Metrics.gauge('load-avg', loadavg[0])
  249. }
  250. const ts = compileTimer.done()
  251. logger.debug(
  252. {
  253. projectId: request.project_id,
  254. userId: request.user_id,
  255. timeTaken: ts,
  256. stats,
  257. timings,
  258. loadavg,
  259. },
  260. 'done compile'
  261. )
  262. if (stats['latex-runs'] > 0) {
  263. Metrics.histogram(
  264. 'avg-compile-per-pass-v2',
  265. ts / stats['latex-runs'],
  266. COMPILE_TIME_BUCKETS,
  267. request.metricsOpts
  268. )
  269. Metrics.timing(
  270. 'avg-compile-per-pass-v2',
  271. ts / stats['latex-runs'],
  272. 1,
  273. request.metricsOpts
  274. )
  275. }
  276. if (stats['latex-runs'] > 0 && timings['cpu-time'] > 0) {
  277. Metrics.timing(
  278. 'run-compile-cpu-time-per-pass',
  279. timings['cpu-time'] / stats['latex-runs'],
  280. 1,
  281. request.metricsOpts
  282. )
  283. }
  284. // Emit compile time.
  285. timings.compile = ts
  286. const { outputFiles, buildId } = await _saveOutputFiles({
  287. request,
  288. compileDir,
  289. resourceList,
  290. stats,
  291. timings,
  292. })
  293. // Emit e2e compile time.
  294. timings.compileE2E = timerE2E.done()
  295. Metrics.timing('compile-e2e-v2', timings.compileE2E, 1, request.metricsOpts)
  296. if (stats['pdf-size']) {
  297. emitPdfStats(stats, timings, request)
  298. }
  299. return { outputFiles, stats, timings, buildId }
  300. }
  301. async function _saveOutputFiles({
  302. request,
  303. compileDir,
  304. resourceList,
  305. stats,
  306. timings,
  307. }) {
  308. const timer = new Metrics.Timer(
  309. 'process-output-files',
  310. 1,
  311. request.metricsOpts
  312. )
  313. const outputDir = getOutputDir(request.project_id, request.user_id)
  314. const { outputFiles: rawOutputFiles, allEntries } =
  315. await OutputFileFinder.promises.findOutputFiles(resourceList, compileDir)
  316. const { buildId, outputFiles } =
  317. await OutputCacheManager.promises.saveOutputFiles(
  318. { request, stats, timings },
  319. rawOutputFiles,
  320. compileDir,
  321. outputDir
  322. )
  323. timings.output = timer.done()
  324. return { outputFiles, allEntries, buildId }
  325. }
  326. async function stopCompile(projectId, userId) {
  327. const compileName = getCompileName(projectId, userId)
  328. await LatexRunner.promises.killLatex(compileName)
  329. }
  330. async function clearProject(projectId, userId) {
  331. const compileDir = getCompileDir(projectId, userId)
  332. await fsPromises.rm(compileDir, { force: true, recursive: true })
  333. }
  334. async function clearProjectWithListing(projectId, userId, allEntries) {
  335. const compileDir = getCompileDir(projectId, userId)
  336. const exists = await _checkDirectory(compileDir)
  337. if (!exists) {
  338. // skip removal if no directory present
  339. return
  340. }
  341. for (const pathInProject of allEntries) {
  342. const path = Path.join(compileDir, pathInProject)
  343. if (path.endsWith('/')) {
  344. await fsPromises.rmdir(path)
  345. } else {
  346. await fsPromises.unlink(path)
  347. }
  348. }
  349. await fsPromises.rmdir(compileDir)
  350. }
  351. async function _findAllDirs() {
  352. const root = Settings.path.compilesDir
  353. const files = await fsPromises.readdir(root)
  354. const allDirs = files.map(file => Path.join(root, file))
  355. return allDirs
  356. }
  357. async function clearExpiredProjects(maxCacheAgeMs) {
  358. const now = Date.now()
  359. const dirs = await _findAllDirs()
  360. for (const dir of dirs) {
  361. let stats
  362. try {
  363. stats = await fsPromises.stat(dir)
  364. } catch (err) {
  365. // ignore errors checking directory
  366. continue
  367. }
  368. const age = now - stats.mtime
  369. const hasExpired = age > maxCacheAgeMs
  370. if (hasExpired) {
  371. await fsPromises.rm(dir, { force: true, recursive: true })
  372. }
  373. }
  374. }
  375. async function _checkDirectory(compileDir) {
  376. let stats
  377. try {
  378. stats = await fsPromises.lstat(compileDir)
  379. } catch (err) {
  380. if (err.code === 'ENOENT') {
  381. // directory does not exist
  382. return false
  383. }
  384. OError.tag(err, 'error on stat of project directory for removal', {
  385. dir: compileDir,
  386. })
  387. throw err
  388. }
  389. if (!stats.isDirectory()) {
  390. throw new OError('project directory is not directory', {
  391. dir: compileDir,
  392. stats,
  393. })
  394. }
  395. return true
  396. }
  397. async function syncFromCode(projectId, userId, filename, line, column, opts) {
  398. // If LaTeX was run in a virtual environment, the file path that synctex expects
  399. // might not match the file path on the host. The .synctex.gz file however, will be accessed
  400. // wherever it is on the host.
  401. const compileName = getCompileName(projectId, userId)
  402. const baseDir = Settings.path.synctexBaseDir(compileName)
  403. const inputFilePath = Path.join(baseDir, filename)
  404. const outputFilePath = Path.join(baseDir, 'output.pdf')
  405. const command = [
  406. 'synctex',
  407. 'view',
  408. '-i',
  409. `${line}:${column}:${inputFilePath}`,
  410. '-o',
  411. outputFilePath,
  412. ]
  413. const stdout = await _runSynctex(projectId, userId, command, opts)
  414. logger.debug(
  415. { projectId, userId, filename, line, column, command, stdout },
  416. 'synctex code output'
  417. )
  418. return SynctexOutputParser.parseViewOutput(stdout)
  419. }
  420. async function syncFromPdf(projectId, userId, page, h, v, opts) {
  421. const compileName = getCompileName(projectId, userId)
  422. const baseDir = Settings.path.synctexBaseDir(compileName)
  423. const outputFilePath = `${baseDir}/output.pdf`
  424. const command = [
  425. 'synctex',
  426. 'edit',
  427. '-o',
  428. `${page}:${h}:${v}:${outputFilePath}`,
  429. ]
  430. const stdout = await _runSynctex(projectId, userId, command, opts)
  431. logger.debug({ projectId, userId, page, h, v, stdout }, 'synctex pdf output')
  432. return SynctexOutputParser.parseEditOutput(stdout, baseDir)
  433. }
  434. async function _checkFileExists(dir, filename) {
  435. try {
  436. await fsPromises.stat(dir)
  437. } catch (error) {
  438. if (error.code === 'ENOENT') {
  439. throw new Errors.NotFoundError('no output directory')
  440. }
  441. throw error
  442. }
  443. const file = Path.join(dir, filename)
  444. let stats
  445. try {
  446. stats = await fsPromises.stat(file)
  447. } catch (error) {
  448. if (error.code === 'ENOENT') {
  449. throw new Errors.NotFoundError('no output file')
  450. }
  451. }
  452. if (!stats.isFile()) {
  453. throw new Error('not a file')
  454. }
  455. }
  456. async function _runSynctex(projectId, userId, command, opts) {
  457. const { imageName, editorId, buildId, compileFromClsiCache } = opts
  458. if (imageName && !_isImageNameAllowed(imageName)) {
  459. throw new Errors.InvalidParameter('invalid image')
  460. }
  461. if (editorId && !/^[a-f0-9-]+$/.test(editorId)) {
  462. throw new Errors.InvalidParameter('invalid editorId')
  463. }
  464. if (buildId && !OutputCacheManager.BUILD_REGEX.test(buildId)) {
  465. throw new Errors.InvalidParameter('invalid buildId')
  466. }
  467. const outputDir = getOutputDir(projectId, userId)
  468. const runInOutputDir = buildId && CommandRunner.canRunSyncTeXInOutputDir()
  469. const directory = runInOutputDir
  470. ? Path.join(outputDir, OutputCacheManager.CACHE_SUBDIR, buildId)
  471. : getCompileDir(projectId, userId)
  472. const timeout = 60 * 1000 // increased to allow for large projects
  473. const compileName = getCompileName(projectId, userId)
  474. const compileGroup = runInOutputDir ? 'synctex-output' : 'synctex'
  475. const defaultImageName =
  476. Settings.clsi && Settings.clsi.docker && Settings.clsi.docker.image
  477. // eslint-disable-next-line @typescript-eslint/return-await
  478. return await OutputCacheManager.promises.queueDirOperation(
  479. outputDir,
  480. /**
  481. * @return {Promise<string>}
  482. */
  483. async () => {
  484. try {
  485. await _checkFileExists(directory, 'output.synctex.gz')
  486. } catch (err) {
  487. if (
  488. err instanceof Errors.NotFoundError &&
  489. compileFromClsiCache &&
  490. editorId &&
  491. buildId
  492. ) {
  493. try {
  494. await downloadOutputDotSynctexFromCompileCache(
  495. projectId,
  496. userId,
  497. editorId,
  498. buildId,
  499. directory
  500. )
  501. } catch (err) {
  502. logger.warn(
  503. { err, projectId, userId, editorId, buildId },
  504. 'failed to download output.synctex.gz from clsi-cache'
  505. )
  506. }
  507. await _checkFileExists(directory, 'output.synctex.gz')
  508. } else {
  509. throw err
  510. }
  511. }
  512. try {
  513. const output = await CommandRunner.promises.run(
  514. compileName,
  515. command,
  516. directory,
  517. imageName || defaultImageName,
  518. timeout,
  519. {},
  520. compileGroup
  521. )
  522. return output.stdout
  523. } catch (error) {
  524. throw OError.tag(error, 'error running synctex', {
  525. command,
  526. projectId,
  527. userId,
  528. })
  529. }
  530. }
  531. )
  532. }
  533. async function wordcount(projectId, userId, filename, image) {
  534. logger.debug({ projectId, userId, filename, image }, 'running wordcount')
  535. const filePath = `$COMPILE_DIR/${filename}`
  536. const command = ['texcount', '-nocol', '-inc', filePath]
  537. const compileDir = getCompileDir(projectId, userId)
  538. const timeout = 60 * 1000
  539. const compileName = getCompileName(projectId, userId)
  540. const compileGroup = 'wordcount'
  541. if (image && !_isImageNameAllowed(image)) {
  542. throw new Errors.InvalidParameter('invalid image')
  543. }
  544. try {
  545. await fsPromises.mkdir(compileDir, { recursive: true })
  546. } catch (err) {
  547. throw OError.tag(err, 'error ensuring dir for wordcount', {
  548. projectId,
  549. userId,
  550. filename,
  551. })
  552. }
  553. try {
  554. const { stdout } = await CommandRunner.promises.run(
  555. compileName,
  556. command,
  557. compileDir,
  558. image,
  559. timeout,
  560. {},
  561. compileGroup
  562. )
  563. const results = _parseWordcountFromOutput(stdout)
  564. logger.debug(
  565. { projectId, userId, wordcount: results },
  566. 'word count results'
  567. )
  568. return results
  569. } catch (err) {
  570. throw OError.tag(err, 'error reading word count output', {
  571. command,
  572. compileDir,
  573. projectId,
  574. userId,
  575. })
  576. }
  577. }
  578. function _parseWordcountFromOutput(output) {
  579. const results = {
  580. encode: '',
  581. textWords: 0,
  582. headWords: 0,
  583. outside: 0,
  584. headers: 0,
  585. elements: 0,
  586. mathInline: 0,
  587. mathDisplay: 0,
  588. errors: 0,
  589. messages: '',
  590. }
  591. for (const line of output.split('\n')) {
  592. const [data, info] = line.split(':')
  593. if (data.indexOf('Encoding') > -1) {
  594. results.encode = info.trim()
  595. }
  596. if (data.indexOf('in text') > -1) {
  597. results.textWords = parseInt(info, 10)
  598. }
  599. if (data.indexOf('in head') > -1) {
  600. results.headWords = parseInt(info, 10)
  601. }
  602. if (data.indexOf('outside') > -1) {
  603. results.outside = parseInt(info, 10)
  604. }
  605. if (data.indexOf('of head') > -1) {
  606. results.headers = parseInt(info, 10)
  607. }
  608. if (data.indexOf('Number of floats/tables/figures') > -1) {
  609. results.elements = parseInt(info, 10)
  610. }
  611. if (data.indexOf('Number of math inlines') > -1) {
  612. results.mathInline = parseInt(info, 10)
  613. }
  614. if (data.indexOf('Number of math displayed') > -1) {
  615. results.mathDisplay = parseInt(info, 10)
  616. }
  617. if (data === '(errors') {
  618. // errors reported as (errors:123)
  619. results.errors = parseInt(info, 10)
  620. }
  621. if (line.indexOf('!!! ') > -1) {
  622. // errors logged as !!! message !!!
  623. results.messages += line + '\n'
  624. }
  625. }
  626. return results
  627. }
  628. function _isImageNameAllowed(imageName) {
  629. const ALLOWED_IMAGES =
  630. Settings.clsi && Settings.clsi.docker && Settings.clsi.docker.allowedImages
  631. return !ALLOWED_IMAGES || ALLOWED_IMAGES.includes(imageName)
  632. }
  633. module.exports = {
  634. doCompileWithLock: callbackify(doCompileWithLock),
  635. stopCompile: callbackify(stopCompile),
  636. clearProject: callbackify(clearProject),
  637. clearExpiredProjects: callbackify(clearExpiredProjects),
  638. syncFromCode: callbackify(syncFromCode),
  639. syncFromPdf: callbackify(syncFromPdf),
  640. wordcount: callbackify(wordcount),
  641. promises: {
  642. doCompileWithLock,
  643. stopCompile,
  644. clearProject,
  645. clearExpiredProjects,
  646. syncFromCode,
  647. syncFromPdf,
  648. wordcount,
  649. },
  650. }