Skip to content

Commit c08a6c4

Browse files
committed
fix: throttle based on dir + target
1 parent 0c55ab3 commit c08a6c4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/handler.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -531,15 +531,16 @@ export class NodeFsHandler {
531531
directory: string,
532532
initialAdd: boolean,
533533
wh: WatchHelper,
534-
target: Path,
534+
target: Path | undefined,
535535
dir: Path,
536536
depth: number,
537537
throttler: Throttler
538538
): Promise<unknown> | undefined {
539539
// Normalize the directory name on Windows
540540
directory = sp.join(directory, '');
541541

542-
throttler = this.fsw._throttle('readdir', directory, 1000) as Throttler;
542+
const throttleKey = target ? `${directory}:${target}` : directory;
543+
throttler = this.fsw._throttle('readdir', throttleKey, 1000) as Throttler;
543544
if (!throttler) return;
544545

545546
const previous = this.fsw._getWatchedDir(wh.path);
@@ -632,7 +633,7 @@ export class NodeFsHandler {
632633
stats: Stats,
633634
initialAdd: boolean,
634635
depth: number,
635-
target: string,
636+
target: string | undefined,
636637
wh: WatchHelper,
637638
realpath: string
638639
): Promise<(() => void) | undefined> {
@@ -713,7 +714,7 @@ export class NodeFsHandler {
713714
stats,
714715
initialAdd,
715716
depth,
716-
target!,
717+
target,
717718
wh,
718719
targetPath
719720
);

0 commit comments

Comments
 (0)