markgardner / node-flywaydb

NodeJs wrapper for flywaydb cli
Apache License 2.0
60 stars 26 forks source link

Error cleaning up directory on untar failure #25

Closed steven-sheehy closed 3 years ago

steven-sheehy commented 3 years ago

Got an error in my CI when node-flywaydb attempt to untar the binary. Node-flywaydb attempts to cleanup the directory it extracted on error but since it most likely partially extracted some files the rmdir fails with ENOTEMPTY. This in turn hides the real error that caused the untar to fail. Probably recursive=true can be passed to fs.rmdirSync to address this.

Error: Command failed: node node_modules/node-flywaydb/bin/flyway -c .node-flywaydb/config.json clean
tar: flyway-6.5.7/jre/lib/modules: Wrote only 8704 of 10240 bytes
tar: Exiting with failure status due to previous errors
fs.js:130
    throw err;
    ^

Error: ENOTEMPTY: directory not empty, rmdir '/root/project/hedera-mirror-rest/.node-flywaydb/flyway-commandline-6.5.7'
    at Object.rmdirSync (fs.js:763:3)
    at ChildProcess.<anonymous> (/root/project/hedera-mirror-rest/node_modules/node-flywaydb/lib/download.js:223:40)
    at ChildProcess.emit (events.js:209:13)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) {
  errno: -39,
  syscall: 'rmdir',
  code: 'ENOTEMPTY',
  path: '/root/project/hedera-mirror-rest/.node-flywaydb/flyway-commandline-6.5.7'
}

    at ChildProcess.exithandler (child_process.js:295:12)
    at ChildProcess.emit (events.js:209:13)
    at ChildProcess.EventEmitter.emit (domain.js:476:20)
    at maybeClose (internal/child_process.js:1021:16)
    at Socket.<anonymous> (internal/child_process.js:430:11)
    at Socket.emit (events.js:209:13)
    at Socket.EventEmitter.emit (domain.js:476:20)
    at Pipe.<anonymous> (net.js:658:12)
markgardner commented 3 years ago

@steven-sheehy thanks for the report, I'll get a fix in place.