Skip to content

Commit

Permalink
fixup! fix: prevent EMFILE error in environment low file descriptors …
Browse files Browse the repository at this point in the history
…limit
  • Loading branch information
tamoreton committed Jan 5, 2025
1 parent b3c146a commit 66c04b8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions test/content/read.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const getReadStatFailure = (t, err) => getRead(t, {
throw err
},
},
'fs/promises': {
'fs-extra': {
...fs.promises,
stat: async () => {
throw err
Expand Down Expand Up @@ -219,7 +219,7 @@ t.test('read: returns only first result if other hashes fails', function (t) {
t.test('read: opening large files', function (t) {
const CACHE = t.testdir()
const mockedRead = getRead(t, {
'fs/promises': {
'fs-extra': {
...fs.promises,
stat: async () => {
return { size: Number.MAX_SAFE_INTEGER }
Expand Down
4 changes: 2 additions & 2 deletions test/entry-index.insert.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ t.test('ENOENT from appendFile is ignored', async (t) => {
const cache = t.testdir()

const indexMocked = t.mock('../lib/entry-index.js', {
'fs/promises': {
'fs-extra': {
...fs,
appendFile: async () => {
throw Object.assign(new Error('fake enoent'), { code: 'ENOENT' })
Expand All @@ -239,7 +239,7 @@ t.test('generic error from appendFile rejects', async (t) => {
const cache = t.testdir()

const indexMocked = t.mock('../lib/entry-index.js', {
'fs/promises': {
'fs-extra': {
...fs,
appendFile: async () => {
throw Object.assign(new Error('fake eperm'), { code: 'EPERM' })
Expand Down
4 changes: 2 additions & 2 deletions test/entry-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ missingFileError.code = 'ENOENT'

const getEntryIndex = (t, opts) => t.mock('../lib/entry-index', opts)
const getEntryIndexReadFileFailure = (t, err) => getEntryIndex(t, {
'fs/promises': {
'fs-extra': {
...fs.promises,
readFile: async () => {
throw err
Expand Down Expand Up @@ -233,7 +233,7 @@ t.test('lsStream: missing files error', async (t) => {
t.test('lsStream: unknown error reading dirs', (t) => {
const cache = t.testdir(cacheContent)
const { lsStream } = getEntryIndex(t, {
'fs/promises': {
'fs-extra': {
...fs.promises,
readdir: async () => {
throw genericError
Expand Down
6 changes: 3 additions & 3 deletions test/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ t.test('missing file error when validating cache content', async t => {
const missingFileError = new Error('ENOENT')
missingFileError.code = 'ENOENT'
const mockVerify = getVerify(t, {
'fs/promises': Object.assign({}, fs, {
'fs-extra': Object.assign({}, fs, {
stat: async () => {
throw missingFileError
},
Expand All @@ -238,7 +238,7 @@ t.test('missing file error when validating cache content', async t => {

t.test('unknown error when validating content', async t => {
const mockVerify = getVerify(t, {
'fs/promises': Object.assign({}, fs, {
'fs-extra': Object.assign({}, fs, {
stat: async () => {
throw genericError
},
Expand Down Expand Up @@ -274,7 +274,7 @@ t.test('unknown error when rebuilding bucket', async t => {
// shouldFail controls the right time to mock the error
let shouldFail = false
const mockVerify = getVerify(t, {
'fs/promises': Object.assign({}, fs, {
'fs-extra': Object.assign({}, fs, {
stat: async (path) => {
if (shouldFail) {
throw genericError
Expand Down

0 comments on commit 66c04b8

Please sign in to comment.