From 2d48c6cd5895847a812bc327a79f4f996fcd0428 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Mon, 8 Nov 2021 10:18:08 +0100 Subject: [PATCH 1/2] call original fsBinding.open when collecting ReadFileContext proto to avoid creating open handle --- lib/readfilecontext.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/readfilecontext.js b/lib/readfilecontext.js index 4bd66ee..061ced2 100644 --- a/lib/readfilecontext.js +++ b/lib/readfilecontext.js @@ -17,6 +17,7 @@ exports.getReadFileContextPrototype = function() { let proto; fsBinding.open = (_path, _flags, _mode, req) => { proto = Object.getPrototypeOf(req.context); + originalOpen.apply(fsBinding, [_path, _flags, _mode, req]); }; fs.readFile('/ignored.txt', () => {}); From 9bbd98719faa6b080f1f4eea45b865c962b11aec Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Mon, 8 Nov 2021 10:34:50 +0100 Subject: [PATCH 2/2] also return the result of originalOpen --- lib/readfilecontext.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/readfilecontext.js b/lib/readfilecontext.js index 061ced2..bead642 100644 --- a/lib/readfilecontext.js +++ b/lib/readfilecontext.js @@ -17,7 +17,7 @@ exports.getReadFileContextPrototype = function() { let proto; fsBinding.open = (_path, _flags, _mode, req) => { proto = Object.getPrototypeOf(req.context); - originalOpen.apply(fsBinding, [_path, _flags, _mode, req]); + return originalOpen.apply(fsBinding, [_path, _flags, _mode, req]); }; fs.readFile('/ignored.txt', () => {});