frida / frida-compile

Compile a Frida script comprised of one or more Node.js modules
Other
190 stars 48 forks source link

"TypeError: fileSystemEntryExists is not a function" when using --watch #53

Closed natpbs closed 2 years ago

natpbs commented 2 years ago

Hi, thanks for working on frida and its fantastic tooling. I encounter a weird error when using frida-compile with the --watch flag.

Reproduction

Here is a minimum example which generates the error. I ran these commands in a Powershell terminal.

# create a fresh npm project frida-compile-issue
mkdir frida-compile-issue
cd frida-compile-issue
npm init --yes
# install frida-compile
npm install frida-compile@16.1.0
# create an empty agent.ts file
# the file's contents are irrelevant to the issue
New-Item agent.ts
# Posix version of the above command:
#touch agent.ts
# execute frida-compile without the --watch flag and check that it works correctly
npx frida-compile agent.ts --output agent.js
cat agent.js
# up to this point everything worked fine
# execute frida-compile with the --watch flag
npx frida-compile agent.ts --output agent.js --watch 
# the error is encountered

Stack Trace

Here is the output of the frida-compile command executed with the --watch flag as above.

10:43:36 - Starting compilation in watch mode...

file:///C:/Users/IT-PC-HTY4CK3/Documents/Projects/Tools/frida-compile-issue/node_modules/frida-compile/ext/typescript.js:6735
            let watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
                           ^

TypeError: fileSystemEntryExists is not a function
    at fsWatch (file:///C:/Users/IT-PC-HTY4CK3/Documents/Projects/Tools/frida-compile-issue/node_modules/frida-compile/ext/typescript.js:6735:28)
    at Object.watchDirectory (file:///C:/Users/IT-PC-HTY4CK3/Documents/Projects/Tools/frida-compile-issue/node_modules/frida-compile/ext/typescript.js:6670:24)
    at watchDirectory (file:///C:/Users/IT-PC-HTY4CK3/Documents/Projects/Tools/frida-compile-issue/node_modules/frida-compile/ext/typescript.js:116412:75)
    at file:///C:/Users/IT-PC-HTY4CK3/Documents/Projects/Tools/frida-compile-issue/node_modules/frida-compile/ext/typescript.js:116435:30
    at Object.compilerHost.watchTypeRootsDirectory (file:///C:/Users/IT-PC-HTY4CK3/Documents/Projects/Tools/frida-compile-issue/node_modules/frida-compile/ext/typescript.js:124354:68)
    at createTypeRootsWatch (file:///C:/Users/IT-PC-HTY4CK3/Documents/Projects/Tools/frida-compile-issue/node_modules/frida-compile/ext/typescript.js:122753:35)
    at file:///C:/Users/IT-PC-HTY4CK3/Documents/Projects/Tools/frida-compile-issue/node_modules/frida-compile/ext/typescript.js:19647:30
    at Map.forEach (<anonymous>)
    at Object.mutateMap (file:///C:/Users/IT-PC-HTY4CK3/Documents/Projects/Tools/frida-compile-issue/node_modules/frida-compile/ext/typescript.js:19644:16)
    at Object.updateTypeRootsWatch (file:///C:/Users/IT-PC-HTY4CK3/Documents/Projects/Tools/frida-compile-issue/node_modules/frida-compile/ext/typescript.js:122788:20)

System information

Software Version
OS Windows 11
node v16.15.1
npm 8.11.0
frida-compile 16.1.0
oleavr commented 2 years ago

Thanks for reporting! :raised_hands: