Merge pull request #12916 from overleaf/bg-move-stream-buffer-code-to-library

move stream-related code to separate  `@overleaf/stream-utils` library

GitOrigin-RevId: a79a873109b927b4fc0ae36f47d5c67e0df58041
This commit is contained in:
Eric Mc Sween
2023-06-02 08:05:57 +00:00
committed by Copybot
parent 9e154d0857
commit 12e7471213
27 changed files with 467 additions and 279 deletions
@@ -1,7 +1,7 @@
const fs = require('fs')
const path = require('path')
const Settings = require('@overleaf/settings')
const streamBuffers = require('stream-buffers')
const { WritableBuffer } = require('@overleaf/stream-utils')
const { promisify } = require('util')
const Stream = require('stream')
@@ -23,9 +23,7 @@ async function checkCanGetFiles() {
const key = `${projectId}/${fileId}`
const bucket = Settings.filestore.stores.user_files
const buffer = new streamBuffers.WritableStreamBuffer({
initialSize: 100,
})
const buffer = new WritableBuffer({ initialSize: 100 })
const sourceStream = await FileHandler.getFile(bucket, key, {})
try {
+1 -1
View File
@@ -23,6 +23,7 @@
"@overleaf/o-error": "*",
"@overleaf/object-persistor": "*",
"@overleaf/settings": "*",
"@overleaf/stream-utils": "^0.1.0",
"body-parser": "^1.19.0",
"bunyan": "^1.8.15",
"express": "^4.18.2",
@@ -30,7 +31,6 @@
"lodash.once": "^4.1.1",
"node-fetch": "^2.6.7",
"range-parser": "^1.2.1",
"stream-buffers": "~0.2.6",
"tiny-async-pool": "^1.1.0"
},
"devDependencies": {
@@ -137,13 +137,6 @@ describe('Filestore', function () {
expect(body).to.contain('up')
})
it('should send a 200 for the health-check endpoint', async function () {
const response = await fetch(`${filestoreUrl}/health_check`)
expect(response.status).to.equal(200)
const body = await response.text()
expect(body).to.equal('OK')
})
describe('with a file on the server', function () {
let fileId, fileUrl, constantFileContent
@@ -198,6 +191,17 @@ describe('Filestore', function () {
expect(body).to.equal(constantFileContent)
})
it('should send a 200 for the health-check endpoint using the file', async function () {
Settings.health_check = {
project_id: projectId,
file_id: fileId,
}
const response = await fetch(`${filestoreUrl}/health_check`)
expect(response.status).to.equal(200)
const body = await response.text()
expect(body).to.equal('OK')
})
it('should not leak a socket', async function () {
await fetch(fileUrl)
await expectNoSockets()