question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does not work/tests fail on OpenBSD

See original GitHub issue

On OpenBSD, with both node v16.14.2 and v12.22.6, webpack does not recompile when files are changed. It used to work when chokidar was used for file watching, i.e. before watchpack 2.

watchpack version: 2.4.0 webpack version: 5.73.0

The tests fail as well (on main branch, dc690bbaea/2.4.0):

  1) Assumption                                            
       should have a file system with correct mtime behavior (fs.watch):
     Error: Timeout of 20000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/data/git/msander/watchpack/test/Assumption.js)
      at Test.Runnable._timeoutError (/data/git/msander/watchpack/node_modules/mocha/lib/runnable.js:440:10)
      at Timeout.<anonymous> (/data/git/msander/watchpack/node_modules/mocha/lib/runnable.js:251:24)
      at listOnTimeout (node:internal/timers:559:17)
      at processTimers (node:internal/timers:502:7)

  2) Assumption                                            
       should detect removed directory:
     Error: Didn't receive a event about removed directory
      at /data/git/msander/watchpack/test/Assumption.js:334:13
      at Timeout._onTimeout (/data/git/msander/watchpack/test/helpers/TestHelper.js:129:3)
      at listOnTimeout (node:internal/timers:559:17)
      at processTimers (node:internal/timers:502:7)

  3) DirectoryWatcher                                      
       should detect a file change:
     Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/data/git/msander/watchpack/test/DirectoryWatcher.js)
      at Test.Runnable._timeoutError (/data/git/msander/watchpack/node_modules/mocha/lib/runnable.js:440:10)
      at Timeout.<anonymous> (/data/git/msander/watchpack/node_modules/mocha/lib/runnable.js:251:24)
      at listOnTimeout (node:internal/timers:559:17)
      at processTimers (node:internal/timers:502:7)

  4) DirectoryWatcher                                      
       "after each" hook:                                  

      Uncaught AssertionError: expected 1 to equal 0
      + expected - actual                                  

      -1                                                   
      +0                                                   
                                                           
      at Assertion.fail (/data/git/msander/watchpack/node_modules/should/lib/assertion.js:92:17)
      at Assertion.value (/data/git/msander/watchpack/node_modules/should/lib/assertion.js:164:19)
      at checkAllWatcherClosed (/data/git/msander/watchpack/test/helpers/TestHelper.js:25:51)
      at TestHelper.del (/data/git/msander/watchpack/test/helpers/TestHelper.js:64:4)
      at Timeout._onTimeout (/data/git/msander/watchpack/test/helpers/TestHelper.js:129:3)
      at listOnTimeout (node:internal/timers:559:17)
      at processTimers (node:internal/timers:502:7)

  5) ManyWatchers                                          
       "before each" hook for "should watch more than 4096 directories":

      AssertionError: expected 1 to equal 0
      + expected - actual                                  

      -1                                                   
      +0                                                   
                                                           
      at Assertion.fail (/data/git/msander/watchpack/node_modules/should/lib/assertion.js:92:17)
      at Assertion.value (/data/git/msander/watchpack/node_modules/should/lib/assertion.js:164:19)
      at checkAllWatcherClosed (/data/git/msander/watchpack/test/helpers/TestHelper.js:25:51)
      at TestHelper.before [as _before] (/data/git/msander/watchpack/test/helpers/TestHelper.js:41:2)
      at Context.TestHelper.before (/data/git/msander/watchpack/test/helpers/TestHelper.js:32:8)
      at callFnAsync (/data/git/msander/watchpack/node_modules/mocha/lib/runnable.js:400:21)
      at Hook.Runnable.run (/data/git/msander/watchpack/node_modules/mocha/lib/runnable.js:342:7)
      at next (/data/git/msander/watchpack/node_modules/mocha/lib/runner.js:317:10)
      at Immediate._onImmediate (/data/git/msander/watchpack/node_modules/mocha/lib/runner.js:347:5)
      at processImmediate (node:internal/timers:466:21)

  6) ManyWatchers                                                                                                      
       "after each" hook:                                                                                              
                                                                                                                       
      Uncaught AssertionError: expected 1 to equal 0   
      + expected - actual                                  
                                                           
      -1                                                   
      +0                                                   
                                                           
      at Assertion.fail (/data/git/msander/watchpack/node_modules/should/lib/assertion.js:92:17)
      at Assertion.value (/data/git/msander/watchpack/node_modules/should/lib/assertion.js:164:19)
      at checkAllWatcherClosed (/data/git/msander/watchpack/test/helpers/TestHelper.js:25:51)
      at TestHelper.del (/data/git/msander/watchpack/test/helpers/TestHelper.js:64:4)
      at Timeout._onTimeout (/data/git/msander/watchpack/test/helpers/TestHelper.js:129:3)
      at listOnTimeout (node:internal/timers:559:17)                                                                   
      at processTimers (node:internal/timers:502:7)                                                                    
                                                                                                                       
  7) Watchpack                                                                                                         
       "before each" hook for "should watch a single file":                               
                                                           
      AssertionError: expected 1 to equal 0        
      + expected - actual                                  

      -1                                                   
      +0                                                   
                                                           
      at Assertion.fail (/data/git/msander/watchpack/node_modules/should/lib/assertion.js:92:17)
      at Assertion.value (/data/git/msander/watchpack/node_modules/should/lib/assertion.js:164:19)
      at checkAllWatcherClosed (/data/git/msander/watchpack/test/helpers/TestHelper.js:25:51)
      at TestHelper.before [as _before] (/data/git/msander/watchpack/test/helpers/TestHelper.js:41:2)
      at Context.TestHelper.before (/data/git/msander/watchpack/test/helpers/TestHelper.js:32:8)
      at callFnAsync (/data/git/msander/watchpack/node_modules/mocha/lib/runnable.js:400:21)
      at Hook.Runnable.run (/data/git/msander/watchpack/node_modules/mocha/lib/runnable.js:342:7)
      at next (/data/git/msander/watchpack/node_modules/mocha/lib/runner.js:317:10)
      at Immediate._onImmediate (/data/git/msander/watchpack/node_modules/mocha/lib/runner.js:347:5)
      at processImmediate (node:internal/timers:466:21)

  8) Watchpack                                             
       "after each" hook:                                  

      Uncaught AssertionError: expected 1 to equal 0
      + expected - actual                                  

      -1                                                   
      +0                                                   
                                                           
      at Assertion.fail (/data/git/msander/watchpack/node_modules/should/lib/assertion.js:92:17)
      at Assertion.value (/data/git/msander/watchpack/node_modules/should/lib/assertion.js:164:19)
      at checkAllWatcherClosed (/data/git/msander/watchpack/test/helpers/TestHelper.js:25:51)
      at TestHelper.del (/data/git/msander/watchpack/test/helpers/TestHelper.js:64:4)
      at Timeout._onTimeout (/data/git/msander/watchpack/test/helpers/TestHelper.js:129:3)
      at listOnTimeout (node:internal/timers:559:17)
      at processTimers (node:internal/timers:502:7)

The tests pass for the last watchpack 1 release…

I realize that this is probably an issue with the underlying fs.watch implementation, but do you have any hints on how I could get webpack working properly? Relying on polling is not an option, as it utilizes 100% CPU when used with any reasonable polling interval. Other solutions that rely on kqueue (e.g. https://github.com/guard/guard) do work, so it cannot be impossible. I would like to use one of those, is it possible to notify webpack of changed files e.g. via a notification on a port or domain socket? Could this be achieved in a plugin?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
marvinthepacommented, Aug 1, 2022

I had a look through the solutions, and if my (very limited) understanding is correct, fixing this in watchpack would require significant changes. For example, using a watcher per directory is not sufficient, as changes to files do not trigger a change event on the containing directory - you need an extra DirectoryWatcher per file (making it a misnomer), and you have to manage them as well. I don’t think I will find the time to fix this in the near future.

I will not close this issue though, I still find some hope that somebody else wants to tackle this. Would be interesting if this is an issue on other BSDs as well…

It seems to me the whole “watching files” thing is very frustrating on node. Mainly because node itself does not really provide a platform-agnostic API…

0reactions
alexander-akaitcommented, Jul 29, 2022

@marvinthepa chokidar has many perf problems and required a compilation after instalattion (this is not a problem, but happens for wsl and other exotic systems/subsystems)

Read more comments on GitHub >

github_iconTop Results From Across the Web

One unit test is failing on OpenBSD and FreeBSD #504 - GitHub
One test fails when running make test on OpenBSD or FreeBSD: 99% tests passed, 1 tests failed out of 104 Total Test time...
Read more >
bsd.regress.mk(5) - OpenBSD manual pages
If one of the tests fails, the line "FAILED" is printed to the standard output. By default, execution continues with the next test...
Read more >
Test Stork on FreeBSD and OpenBSD (#193) · Issues - GitLab
So far we're running Stork on Ubuntu and did some quick tests on FreeBSD ... I use openbsd and I get this error...
Read more >
PF: Testing Your Firewall - OpenBSD Journal
But, of course, a ruleset can produce the wrong output at run-time, by blocking or passing packets that it shouldn't according to the...
Read more >
Check | Installing Check
Check unit testing framework for C. ... OpenBSD via Packages; From Source. Windows ... Debian GNU/Hurd does not yet provide a package for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found