From fb5b51f88b4c9526f266cf7ec7be7383c639d942 Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Wed, 13 May 2015 02:51:41 +0200 Subject: [PATCH] add 3s timeout to unmount since fuse sometimes fails --- index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 7ab83f5..d9127db 100644 --- a/index.js +++ b/index.js @@ -83,7 +83,16 @@ exports.mount = function (mnt, ops, cb) { } exports.unmount = function (mnt, cb) { - fuse.unmount(path.resolve(mnt), cb || noop) + var timeout = setTimeout(function () { + var err = new Error('Unmount took too long') + err.code = 'ETIMEDOUT' + if (cb) cb(err) + }, 2000) + + fuse.unmount(path.resolve(mnt), function (err) { + clearTimeout(timeout) + if (cb) cb(err) + }) } exports.errno = function (code) {