Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitede0f4f

Browse files
authored
fix: don't fail on closing fd after reset has been called (#550) (#1081)
* fix: don't fail on closing fd after reset has been called (#550)* fix: only skip EBADF errors on async close and only when aborted* fix: remove abortControllers and just call closeFile asynchronously fromclose
1 parentf389874 commitede0f4f

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

‎src/__tests__/volume.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,23 @@ describe('volume', () => {
361361
'/good':'bye',
362362
});
363363
});
364+
it('Open streams should not be affected',async()=>{
365+
constvol=newVolume();
366+
constjson={
367+
'/hello':'world',
368+
};
369+
vol.fromJSON(json);
370+
awaitnewPromise((resolve,reject)=>{
371+
vol
372+
.createReadStream('/hello')
373+
.on('data',()=>null)
374+
.on('close',resolve)
375+
.on('end',()=>{
376+
vol.reset();
377+
})
378+
.on('error',reject);
379+
});
380+
});
364381
});
365382
describe('.openSync(path, flags[, mode])',()=>{
366383
constvol=newVolume();

‎src/volume.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,9 @@ export class Volume implements FsCallbackApi, FsSynchronousApi {
825825

826826
close(fd:number,callback:TCallback<void>){
827827
validateFd(fd);
828-
this.wrapAsync(this.closeSync,[fd],callback);
828+
constfile=this.getFileByFdOrThrow(fd,'close');
829+
// NOTE: not calling closeSync because we can reset in between close and closeSync
830+
this.wrapAsync(this.closeFile,[file],callback);
829831
}
830832

831833
privateopenFileOrGetById(id:TFileId,flagsNum:number,modeNum?:number):File{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp