fix(smartfs.provider.node): replace synchronous readdirSync with async await fs.readdir for directory listings in the Node provider to avoid blocking the event loop
This commit is contained in:
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartfs',
|
||||
version: '1.3.2',
|
||||
version: '1.3.3',
|
||||
description: 'a cross platform extendable fs module'
|
||||
}
|
||||
|
||||
@@ -158,11 +158,7 @@ export class SmartFsProviderNode implements ISmartFsProvider {
|
||||
if (options?.recursive) {
|
||||
await this.listDirectoryRecursive(path, entries, options);
|
||||
} else {
|
||||
// Use readdirSync for reliability — async readdir can return partial results
|
||||
// on XFS/mounted filesystems when the process receives signals (e.g., from
|
||||
// SmartExit/smartshell process group management). The synchronous version
|
||||
// completes the entire getdents64 syscall without event loop interruption.
|
||||
const dirents = fsSync.readdirSync(path, { withFileTypes: true });
|
||||
const dirents = await fs.readdir(path, { withFileTypes: true });
|
||||
|
||||
for (const dirent of dirents) {
|
||||
const entryPath = pathModule.join(path, dirent.name);
|
||||
@@ -200,8 +196,7 @@ export class SmartFsProviderNode implements ISmartFsProvider {
|
||||
entries: IDirectoryEntry[],
|
||||
options?: IListOptions,
|
||||
): Promise<void> {
|
||||
// Use readdirSync for reliability — see listDirectory comment
|
||||
const dirents = fsSync.readdirSync(path, { withFileTypes: true });
|
||||
const dirents = await fs.readdir(path, { withFileTypes: true });
|
||||
|
||||
for (const dirent of dirents) {
|
||||
const entryPath = pathModule.join(path, dirent.name);
|
||||
|
||||
Reference in New Issue
Block a user