From b68f3e42087ae777f37308a48d6aa23cc95ae3fb Mon Sep 17 00:00:00 2001 From: nadav mizrahi Date: Wed, 19 Feb 2025 14:58:40 +0200 Subject: [PATCH] NSFS | close stream when getting empty content dir --- src/sdk/namespace_fs.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sdk/namespace_fs.js b/src/sdk/namespace_fs.js index 51bf651d95..1f731540a4 100644 --- a/src/sdk/namespace_fs.js +++ b/src/sdk/namespace_fs.js @@ -1021,8 +1021,12 @@ class NamespaceFS { // NOTE: don't move this code after the open // this can lead to ENOENT failures due to file not exists when content size is 0 - // if entry is a directory object and its content size = 0 - return empty response - if (await this._is_empty_directory_content(file_path, fs_context, params)) return null; + // if entry is a directory object and its content size = 0 - close the stream and return empty response + if (await this._is_empty_directory_content(file_path, fs_context, params)) { + res.end(); + await stream_utils.wait_finished(res, { signal: object_sdk.abort_controller.signal }); + return null; + } file = await nb_native().fs.open( fs_context,