mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2025-07-26 05:00:06 +02:00

* [docstore] DocManager.getDocLines returns flat content * [docstore] peekDoc throws NotFoundError, skip check in HttpController * [docstore] getFullDoc throws NotFoundError, skip check in HttpController * [docstore] migrate HealthChecker to async/await * [docstore] migrate HttpController to async/await * [docstore] remove .promises/callbackify wrapper from all the modules GitOrigin-RevId: a9938b03cdd2b5e80c2c999039e8f63b20d59dc5
24 lines
701 B
JavaScript
24 lines
701 B
JavaScript
const { LoggerStream, WritableBuffer } = require('@overleaf/stream-utils')
|
|
const Settings = require('@overleaf/settings')
|
|
const logger = require('@overleaf/logger/logging-manager')
|
|
const { pipeline } = require('node:stream/promises')
|
|
|
|
module.exports = {
|
|
streamToBuffer,
|
|
}
|
|
|
|
async function streamToBuffer(projectId, docId, stream) {
|
|
const loggerTransform = new LoggerStream(
|
|
Settings.max_doc_length,
|
|
(size, isFlush) => {
|
|
logger.warn(
|
|
{ projectId, docId, size, finishedReading: isFlush },
|
|
'potentially large doc pulled down from gcs'
|
|
)
|
|
}
|
|
)
|
|
|
|
const buffer = new WritableBuffer()
|
|
await pipeline(stream, loggerTransform, buffer)
|
|
return buffer.contents()
|
|
}
|