jfischoff/twitch

Some errors on mac os

k-bx opened this issue · 8 comments

k-bx commented

Hey! So I just wrote small script like this:

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes       #-}

import           FileCommand
import           Twitch

main :: IO ()
main = defaultMain $ do
  "*.jsx" |> [s|make static|]

Upon launch it waits for some time, and then throws bunch of output at me:

➜  beanstalk_consumer_hk git:(master) ✗ ./dist/build/WatchStatic/WatchStatic
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
WatchStatic: <file descriptor: 1024>: hGetBuf: invalid argument (Invalid argument)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
WatchStatic: <file descriptor: 1026>: hGetBuf: invalid argument (Invalid argument)
2014-12-23 19:34 WatchStatic[62337] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
WatchStatic: <file descriptor: 1028>: hGetBuf: invalid argument (Invalid argument)
...(and lots more infinitely)

I did some research, and this is an issue that effects many watchers on OSX.

From what I can gather, there is an error early in initialization that is not propagated, and later the watchers fail because they are in a bad state. I will see if I can rework the use of FSNotify to get around this, otherwise I will file an issue with their repo.

Sometimes restarting fixes it. The real fix is to fail earlier and display a more informative error message.

Now there is something else that could be going on. Are you running in non-threaded mode? You only get 1024 file handles in non-threaded mode which could explain this message:

WatchStatic: <file descriptor: 1024>: hGetBuf: invalid argument (Invalid argument)

Also how many files are in that directory? Are you running this with ghci or are you building an exe?

k-bx commented

I'm building an exe. You were right, I forgot to put "ghc options" for this new executable, so it wasn't in threading and even wasn't optimized. Will add and check now.

No, still gives:

...
2014-12-24 09:19 WatchStatic[90047] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
WatchStatic: <file descriptor: 1631>: hGetBuf: invalid argument (Invalid argument)
2014-12-24 09:19 WatchStatic[90047] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
WatchStatic: <file descriptor: 1633>: hGetBuf: invalid argument (Invalid argument)
2014-12-24 09:19 WatchStatic[90047] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
WatchStatic: <file descriptor: 1256>: hGetBuf: invalid argument (Invalid argument)
2014-12-24 09:19 WatchStatic[90047] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
...

Problem is consistent on every start.

There are 8890 files in project directory 4 of them are under glob pattern I used.

I will do a bit of debugging today, as you mentioned "getting better error-message is a real fix".

Thanks for the input :)

k-bx commented

Btw, after 2 or 3 seconds it says "Type anything to quit" and quits.

k-bx commented

Btw, running as:

./dist/build/WatchStatic/WatchStatic --directories "[\"./resources\"]"

helped to not get errors, but at the same time it doesn't do anything upon file created in that resources path. Fullpath didn't help.

k-bx commented

Ha! Interesting. So it turns out twitch works after all (without that --directories being passed). Touching some jsx file did run the command.

So, now I'm only confused:

  1. why that --directories option didn't work (it doesn't produce that many errors, but also doesn't listen to new files)
  2. can we make it more user-friendly to pass :)

This might be separate issue.

k-bx commented

After debugging I see the reason why --directories doesn't work as I want it to. Even when --directories is passed, Twitch.Rule.compilePattern still compiles pattern to /Users/kb/workspace/twitchtest/*.jsx, not /Users/kb/workspace/twitchtest/resources/*.jsx as I would expect. But at least I know how to fix it -- I should make a pattern **/*.jsx and everything works!

k-bx commented

I presume errors would still happen on big directories, so maybe it's too early to close this one. Thanks for fixing others anyway, will definitely use those!

Fair enough, reopening to make it easier for others to find your workaround.