Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs.close() callback not provided in write-entry.js. #231

Closed
EmGustave opened this issue Sep 23, 2019 · 1 comment
Closed

fs.close() callback not provided in write-entry.js. #231

EmGustave opened this issue Sep 23, 2019 · 1 comment

Comments

@EmGustave
Copy link

EmGustave commented Sep 23, 2019

I started seeing this error today:

fs.js:136
    throw new ERR_INVALID_CALLBACK();
    ^

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
    at makeCallback (fs.js:136:11)
    at Object.close (fs.js:394:20)
    at Object.[close] (/home/dev/repo/node_modules/tar/lib/write-entry.js:225:8)    
    at Object.[onread] (/home/dev/repo/node_modules/tar/lib/write-entry.js:243:18)  
    at fs.read (/home/dev/repo/node_modules/tar/lib/write-entry.js:220:19)
    at FSReqWrap.wrapper [as oncomplete] (fs.js:467:17)   

We're using tar v4.4.11. This error occurs when executing a tar.create() function on Ubuntu (Node v10.16.1) , but not on Windows (Node v12.4).

I think the issue is with the second parameter to the fs.close() function. Since Node v10 a callback is required as the second parameter.

In the lib/write-entry.js, that callback is not always provided. It's provided here:
https://github.com/npm/node-tar/blob/9232b3d7da934c142e3d0ab97ef35ec0ba3917fc/lib/write-entry.js#L219
and here:
https://github.com/npm/node-tar/blob/9232b3d7da934c142e3d0ab97ef35ec0ba3917fc/lib/write-entry.js#L269
But not here:
https://github.com/npm/node-tar/blob/9232b3d7da934c142e3d0ab97ef35ec0ba3917fc/lib/write-entry.js#L234
nor here:
https://github.com/npm/node-tar/blob/9232b3d7da934c142e3d0ab97ef35ec0ba3917fc/lib/write-entry.js#L243

I'm not sure how Node API changes are handled within this library so I can't send some code. I think there either needs to be code to check the Node version and act appropriately, or a specific version needs to be used as the default (ie. the latest one where the callback is required.)

@EmGustave EmGustave changed the title fs.close() callback not provided. fs.close() callback not provided in write-entry.js. Sep 23, 2019
@isaacs isaacs closed this as completed in d04c3ff Sep 25, 2019
@isaacs
Copy link
Owner

isaacs commented Sep 25, 2019

Yeah, that's definitely an issue. I was scratching my head because I could've sworn I'd fixed this, but it turns out I'd only fixed it on the v5 branch :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants