Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition prevents cleaning of dist folder between rebuilds #246

Closed
jurecuhalev opened this issue Aug 3, 2016 · 20 comments
Closed

Comments

@jurecuhalev
Copy link

jurecuhalev commented Aug 3, 2016

The first time I run a fastboot on a simple project, it works. Second time it crashes:

➜  moment-fastboot-example git:(master) NODE_DEBUG=fs ember fastboot --serve-assets
Installing FastBoot npm dependencies

Build successful - 12390ms.

Slowest Trees                                 | Total               
----------------------------------------------+---------------------
Babel                                         | 4257ms              
Babel                                         | 2892ms              
Babel                                         | 689ms               

Slowest Trees (cumulative)                    | Total (avg)         
----------------------------------------------+---------------------
Babel (30)                                    | 9917ms (330 ms)     

DEBUG: -------------------------------
DEBUG: Ember      : 2.7.0
DEBUG: Ember Data : 2.7.0
DEBUG: -------------------------------
Ember FastBoot running at http://[::]:3000
^C%                                                                                                                                                                                                                                                                          ➜  moment-fastboot-example git:(master) NODE_DEBUG=fs ember fastboot --serve-assets
Installing FastBoot npm dependencies

Build successful - 2498ms.

Slowest Trees                                 | Total               
----------------------------------------------+---------------------
SourceMapConcat: Concat: Vendor /assets/ve... | 135ms               

Slowest Trees (cumulative)                    | Total (avg)         
----------------------------------------------+---------------------
Babel (30)                                    | 678ms (22 ms)       
SourceMapConcat: Concat: Vendor /asset... (2) | 257ms (128 ms)      
JSHint templates (2)                          | 155ms (77 ms)       

fs.js:88
        throw backtrace;
        ^

Error: ENOTEMPTY: directory not empty, rmdir '/Users/gandalf/hacking/fastboot/moment-fastboot-example/dist/node_modules/moment/src/'
    at rethrow (fs.js:83:21)
    at maybeCallback (fs.js:101:42)
    at Object.fs.rmdir (fs.js:871:14)
    at TreeSync.<anonymous> (/Users/gandalf/hacking/fastboot/moment-fastboot-example/node_modules/tree-sync/index.js:79:19)
    at Array.forEach (native)
    at TreeSync.sync (/Users/gandalf/hacking/fastboot/moment-fastboot-example/node_modules/tree-sync/index.js:50:14)
    at CoreObject.module.exports.Task.extend.copyToOutputPath (/Users/gandalf/hacking/fastboot/moment-fastboot-example/node_modules/ember-cli/lib/models/builder.js:173:10)
    at /Users/gandalf/hacking/fastboot/moment-fastboot-example/node_modules/ember-cli/lib/models/builder.js:187:21
    at lib$rsvp$$internal$$tryCatch (/Users/gandalf/hacking/fastboot/moment-fastboot-example/node_modules/rsvp/dist/rsvp.js:493:16)
    at lib$rsvp$$internal$$invokeCallback (/Users/gandalf/hacking/fastboot/moment-fastboot-example/node_modules/rsvp/dist/rsvp.js:505:17)

Repository that I used to test: https://github.com/gandalfar/moment-fastboot-example

➜  moment-fastboot-example git:(master) ember -v
ember-cli: 2.7.0
node: 6.2.1
os: darwin x64

Connected ticket with a bit more discussion: jasonmit/ember-cli-moment-shim#55

@jurecuhalev
Copy link
Author

In addition to that, if I remove dist so it would get regenerated, it fails to regenerated it correctly. It works correctly with ember s.

➜  moment-fastboot-example git:(master) rm -rf dist                  
➜  moment-fastboot-example git:(master) ember fastboot --serve-assets
Installing FastBoot npm dependencies

Build successful - 2703ms.

Slowest Trees                                 | Total               
----------------------------------------------+---------------------
SourceMapConcat: Concat: Vendor /assets/ve... | 135ms               

Slowest Trees (cumulative)                    | Total (avg)         
----------------------------------------------+---------------------
Babel (30)                                    | 728ms (24 ms)       
SourceMapConcat: Concat: Vendor /asset... (2) | 269ms (134 ms)      
JSHint templates (2)                          | 204ms (102 ms)      

There was an error trying to run your application in FastBoot.

This is usually caused by either your application code or an addon trying to access an API that isn't available in Node.js.
Based on the stack trace, it looks like the exception was generated in util.js on line 1007.
The exception is probably coming from your app. Look at this file and line number to determine what is triggering the exception.

The full stack trace is:

spawn /bin/sh ENOENT
Error: spawn /bin/sh ENOENT
    at exports._errnoException (util.js:1007:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:182:32)
    at onErrorNT (internal/child_process.js:348:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

@jurecuhalev
Copy link
Author

jurecuhalev commented Aug 3, 2016

Running ember s also fixes fastboot. So that it runs once correctly again.

@Jarred-Sumner
Copy link

Jarred-Sumner commented Aug 12, 2016

I'm running into this issue too.

@josemarluedke
Copy link
Contributor

I'm also running into this issue.

@alidcast
Copy link

Is this fixed yet? I also ran into the couldn't find package.json issue. I ran ember build and tried again, and now I'm getting an document is not defined error.

@ptomasroos
Copy link

I'm having the same problem

@marcemira
Copy link

Hello, same here! 👋

@bigredwill
Copy link

There is a fix by @danmcclain #269 github.com/ember-fastboot/ember-cli-fastboot/pull/269

I tested it out and it solves this issue 😄

@stefanpenner
Copy link
Contributor

stefanpenner commented Oct 7, 2016

I believe the root cause is, the fastboot server incorrectly serves from dist not from the output of the build. Note, dist is merely a user friendly reflection of the last build (be that test or build or server or ...).

the following would most likely address this issue: #274

and concretely, not having node_modules in dist would also mitigate (atleast the exact failure) #269

@danmcclain
Copy link
Member

My fix is also temporary until the solution in #274 lands. 274 is the Way of the Future™

@stefanpenner
Copy link
Contributor

@danmcclain i believe both are complementary.

@josemarluedke
Copy link
Contributor

Hey @danmcclain I think your fix will be necessary to solve this issue.

I just tested out all the work that @kratiahuja has done with building FastBoot in Ember CLI with the hope this problem was solved, however, it did not solve this specific issue.

I have a reproduction here: https://github.com/josemarluedke/fastboot-build-spike which is just a fork from @kratiahuja repo but with an addition of a FastBoot dependency.

@danmcclain @kratiahuja Is there anything I can help with to get it fixed?

@kratiahuja btw, amazing job in the Ember CLI build with FastBoot! \o/

@kratiahuja
Copy link
Contributor

@josemarluedke I think this bug still talks about ember fastboot --serve-assets. While my work pushed upstream till now is only on the build part. If you want to test with the build part, you can use this gist.

I have the changes for #274 locally (from ember-cli API side changes) but where we will be able to serve from tmp and not dist directory. However I haven't pushed it upstream yet 😄 . I need to put out an RFC in ember-cli for that.

@josemarluedke
Copy link
Contributor

@kratiahuja I see now. Thanks for working on this. Yes, I tested your stuff using your gist, that was very helpful.

@Blackening999
Copy link

When I update some file, fastboot crashed and any subsequent attempts to make it work fails until full npm/bower clean and reinstall:

[Blacks-MacBook-Pro 112] ~/Work/My_Projects/proj-fastboot > ember fastboot --serve-assets
DEPRECATION: ember-addon.fastBootDependencies has been replaced with ember-addon.fastbootDependencies [addon: ember-network]
Installing FastBoot npm dependencies

Build successful - 2025ms.



Slowest Nodes (totalTime => 5% )              | Total (avg)         
----------------------------------------------+---------------------
Babel (24)                                    | 653ms (27 ms)       
Concat (16)                                   | 388ms (24 ms)       
Funnel (55)                                   | 183ms (3 ms)        

fs.js:101
      throw err;  // Forgot a callback but don't know where? Use NODE_DEBUG=fs
      ^

Error: ENOTEMPTY: directory not empty, rmdir '/Users/black/Work/My_Projects/proj-fastboot/dist/node_modules/node-fetch/node_modules/iconv-lite/encodings/'
    at Error (native)

@danmcclain
Copy link
Member

@Blackening999 remove your dist/node_modules folder to get past this. It's because we are still calling npm install in the ember fastboot command

@kratiahuja
Copy link
Contributor

This should be solved by #356 . We should close this once that lands.

@ptomasroos
Copy link

Great news!

@stefanpenner
Copy link
Contributor

master (soon rc.1) should address this

@1337-ishaan
Copy link

**> Cannot find module 'node-fetch' from 'script2.test.js' **

Hey team!
Im getting this error even though i have installed the node-fetch package and also require_d_ it in script2.js and script2.js,
Please help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests