edsu / anon

tweet about anonymous Wikipedia edits from particular IP address ranges
Creative Commons Zero v1.0 Universal
973 stars 152 forks source link

fs.unlink should probably be fs.unlinkSync #171

Closed tomcardoso closed 5 years ago

tomcardoso commented 5 years ago

Was getting the error below:

fs.js:149 
State changed from up to crashed 
    throw new ERR_INVALID_CALLBACK(cb); 
    ^ 
TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received undefined 
    at makeCallback (fs.js:149:11) 
    at Object.unlink (fs.js:996:14) 
    at /app/anon.js:211:16 
    at /app/node_modules/twit/lib/twitter.js:127:13 
    at onRequestComplete (/app/node_modules/twit/lib/twitter.js:352:5) 
    at Request.<anonymous> (/app/node_modules/twit/lib/twitter.js:364:7) 
    at Request.emit (events.js:201:15) 
    at IncomingMessage.<anonymous> (/app/node_modules/request/request.js:1079:12) 
    at Object.onceWrapper (events.js:284:20) 
    at IncomingMessage.emit (events.js:201:15) 
    at endReadableNT (_stream_readable.js:1130:12) 
    at processTicksAndRejections (internal/process/task_queues.js:83:17) 

Per the error, the problem was with line 211, which runs fs.unlink(screenshot). Looks like fs.unlink expects a second param (a callback), so fixed it by changing to fs.unlinkSync(screenshot).

edsu commented 5 years ago

Odd, I don't know why nobody has run into that before, and the test suite passes without it. Maybe something with Node versions? At any rate I applied your change.