{"action":"created","issue":{"url":"https://api.github.com/repos/paulmillr/chokidar/issues/450","repository_url":"https://api.github.com/repos/paulmillr/chokidar","labels_url":"https://api.github.com/repos/paulmillr/chokidar/issues/450/labels{/name}","comments_url":"https://api.github.com/repos/paulmillr/chokidar/issues/450/comments","events_url":"https://api.github.com/repos/paulmillr/chokidar/issues/450/events","html_url":"https://github.com/paulmillr/chokidar/issues/450","id":140758502,"number":450,"title":"Missed 'unlink' events with cwd + awf","user":{"login":"nono","id":2767,"avatar_url":"https://avatars.githubusercontent.com/u/2767?v=3","gravatar_id":"","url":"https://api.github.com/users/nono","html_url":"https://github.com/nono","followers_url":"https://api.github.com/users/nono/followers","following_url":"https://api.github.com/users/nono/following{/other_user}","gists_url":"https://api.github.com/users/nono/gists{/gist_id}","starred_url":"https://api.github.com/users/nono/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nono/subscriptions","organizations_url":"https://api.github.com/users/nono/orgs","repos_url":"https://api.github.com/users/nono/repos","events_url":"https://api.github.com/users/nono/events{/privacy}","received_events_url":"https://api.github.com/users/nono/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-14T18:28:19Z","updated_at":"2016-03-14T19:12:11Z","closed_at":null,"body":"Hello,\r\n\r\nI've been tracking a bug in chokidar where some 'unlink' events are not fired. I'm pretty sure it's in chokidar code, as some events are fired in for a path and later the same path is no longer in `getWatched()` and no `unlink` event have been fired for it.\r\n\r\nI've added some console.log in chokidar code to try to understand what happened. I think its cwd + awf + a file updated and then moved.\r\n\r\nhttps://github.com/paulmillr/chokidar/blob/master/index.js#L516-L520\r\nHere, `path` is absolute but `this._pendingWrites` has relative paths as keys. So, `cancelWait` is not called and `this._pendingWrites` still has an entry for the relative path associated to path when `_emit` is called.\r\n\r\nhttps://github.com/paulmillr/chokidar/blob/master/index.js#L144 +\r\nhttps://github.com/paulmillr/chokidar/blob/master/index.js#L151\r\nHere, the path is set relative to cwd. Thus, it is found in `this._pendingWrites` and the emit is cancelled.\r\n\r\nIf I am right, to fix it, we have to transform `path` in a relative path before checking it in `cancelWait`. But it's not enough.\r\n\r\nIn theory, awf makes an `add` and an `unlink` events to cancel. But, here, it's a `change` and an `unlink`, so only the update should be canceled. Should we track if the first event of awf is an `add` or a `change` to and return it to `cancelWait`, in order to `return` or not here: https://github.com/paulmillr/chokidar/blob/master/index.js#L519?"},"comment":{"url":"https://api.github.com/repos/paulmillr/chokidar/issues/comments/196480435","html_url":"https://github.com/paulmillr/chokidar/issues/450#issuecomment-196480435","issue_url":"https://api.github.com/repos/paulmillr/chokidar/issues/450","id":196480435,"user":{"login":"es128","id":1740641,"avatar_url":"https://avatars.githubusercontent.com/u/1740641?v=3","gravatar_id":"","url":"https://api.github.com/users/es128","html_url":"https://github.com/es128","followers_url":"https://api.github.com/users/es128/followers","following_url":"https://api.github.com/users/es128/following{/other_user}","gists_url":"https://api.github.com/users/es128/gists{/gist_id}","starred_url":"https://api.github.com/users/es128/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/es128/subscriptions","organizations_url":"https://api.github.com/users/es128/orgs","repos_url":"https://api.github.com/users/es128/repos","events_url":"https://api.github.com/users/es128/events{/privacy}","received_events_url":"https://api.github.com/users/es128/received_events","type":"User","site_admin":false},"created_at":"2016-03-14T19:12:11Z","updated_at":"2016-03-14T19:12:11Z","body":"Sounds really complex. Is there a set of steps you can describe or example code that will consistently demonstrate the problem?\r\n\r\ncc/ @alexpusch "}}