Closed ywang-temp closed 2 years ago
Have you found any solution for this issue? because I'm facing the same!
no..
I have seen this error in context of cypress (after upgrade to node 14 from 10) - not sure if its and error of this library or just indication it was used badly
TypeError [ERR_INVALID_ARG_TYPE] [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
at writeFile (fs.js:1436:5)
at go$writeFile (/root/.cache/Cypress/7.3.0/Cypress/resources/app/packages/server/node_modules/graceful-fs/graceful-fs.js:106:14)
at writeFile (/root/.cache/Cypress/7.3.0/Cypress/resources/app/packages/server/node_modules/graceful-fs/graceful-fs.js:103:12)
at go$writeFile (/root/.cache/Cypress/7.3.0/Cypress/resources/app/packages/server/node_modules/fs-extra/node_modules/graceful-fs/graceful-fs.js:139:14)
at Object.writeFile (/root/.cache/Cypress/7.3.0/Cypress/resources/app/packages/server/node_modules/fs-extra/node_modules/graceful-fs/graceful-fs.js:136:12)
at /root/.cache/Cypress/7.3.0/Cypress/resources/app/packages/server/node_modules/fs-extra/lib/output/index.js:18:27
at /root/.cache/Cypress/7.3.0/Cypress/resources/app/packages/server/node_modules/universalify/index.js:23:46
{
code: 'ERR_INVALID_ARG_TYPE'
}
In our case problem was just as an error said - we had a line in our code Cypress.backend("write:file", "marker");
which is in fact missing the 3rd argument - the data
just like traceback said and like other reports suggest https://stackoverflow.com/questions/65137938/typeerror-err-invalid-arg-type-the-data-argument-must-be-of-type-string-or .
So, yea, nodejs fs started to check the data
type more diligently, but that wasn't an issue in node-graceful-fs
itself.
same for open and other methods
same here:
throw error 1 times
TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
at Object.writeFile (fs.js:1487:5)
This is not a graceful-fs bug. The consuming library is passing an invalid argument (ie, not a String or Buffer) to fs.writeFile
, which node 14 no longer allows. (Prior to node 14, it'd coerce to a string, so fs.writeFile(path, undefined)
would write the string 'undefined'
for example. Writing an object would call that object's toString()
method.)
This must be fixed in the calling code.
https://github.com/isaacs/node-graceful-fs/blob/master/graceful-fs.js#L139
TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of XMLElement