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

EEXIST: file already exists | @ngx-cache #631

Open
logan-jobzmall opened this issue Jan 15, 2019 · 5 comments
Open

EEXIST: file already exists | @ngx-cache #631

logan-jobzmall opened this issue Jan 15, 2019 · 5 comments
Projects

Comments

@logan-jobzmall
Copy link

I'm submitting a ... (check one with "x")

[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report  <!-- Please check the repository for a similar issue or PR before submitting -->
[ ] Support request => <!-- Please check the repository for a similar issue or PR before submitting -->
[ ] Feature request
[ ] Documentation issue or request

Current behavior

When running in production SSR mode, ngx-cache fails on second load. It looks like it tries to create the .cache folder twice, and fails:

Error: EEXIST: file already exists, mkdir '/Users/foo/bar/.cache'
    at Object.fs.mkdirSync (fs.js:874:3)
    at new FsStorageService (/Users/foo/bar/node_modules/@ngx-cache/fs-storage/bundles/ngx-cache-fs-storage.umd.js:131:20)
    at _createClass (/Users/foo/bar/node_modules/@angular/core/bundles/core.umd.js:20740:24)
    at _createProviderInstance (/Users/foo/bar/node_modules/@angular/core/bundles/core.umd.js:20712:30)
    at resolveNgModuleDep (/Users/foo/bar/node_modules/@angular/core/bundles/core.umd.js:20676:25)
    at NgModuleRef_.get (/Users/foo/bar/node_modules/@angular/core/bundles/core.umd.js:21384:20)
    at new FsCacheService (/Users/foo/bar/node_modules/@ngx-cache/platform-server/bundles/ngx-cache-platform-server.umd.js:41:39)
    at _createClass (/Users/foo/bar/node_modules/@angular/core/bundles/core.umd.js:20742:24)
    at _createProviderInstance (/Users/foo/bar/node_modules/@angular/core/bundles/core.umd.js:20712:30)
    at resolveNgModuleDep (/Users/foo/bar/node_modules/@angular/core/bundles/core.umd.js:20676:25)

Expected/desired behavior

The expectation is that the cache services should check to see if the folder exists before trying to recreate it. This error breaks everything and shows in the browser.

Minimal reproduction of the problem with instructions

  1. Checkout the latest ng-seed/universal.
  2. Use npm run start:ssr:prod to start on localhost:4000
@shayangz
Copy link

shayangz commented Feb 8, 2019

has anybody figured out how to fix/workaround this?

@raviada
Copy link

raviada commented Feb 9, 2019

I am facing the same issue, any ideas what is happening?

ERROR { Error: EEXIST: file already exists, mkdir '/Users/myself/projects/tools/universal/.cache'
    at Object.mkdirSync (fs.js:774:3)
    at new FsStorageService (/Users/myself/projects/tools/universal/node_modules/@ngx-cache/fs-storage/bundles/ngx-cache-fs-storage.umd.js:131:20)
    at _createClass (/Users/myself/projects/tools/universal/node_modules/@angular/core/bundles/core.umd.js:21185:24)
    at _createProviderInstance (/Users/myself/projects/tools/universal/node_modules/@angular/core/bundles/core.umd.js:21157:30)
    at resolveNgModuleDep (/Users/myself/projects/tools/universal/node_modules/@angular/core/bundles/core.umd.js:21121:25)
    at NgModuleRef_.get (/Users/myself/projects/tools/universal/node_modules/@angular/core/bundles/core.umd.js:21829:20)
    at new FsCacheService (/Users/myself/projects/tools/universal/node_modules/@ngx-cache/platform-server/bundles/ngx-cache-platform-server.umd.js:41:39)
    at _createClass (/Users/myself/projects/tools/universal/node_modules/@angular/core/bundles/core.umd.js:21187:24)
    at _createProviderInstance (/Users/myself/projects/tools/universal/node_modules/@angular/core/bundles/core.umd.js:21157:30)
    at resolveNgModuleDep (/Users/myself/projects/tools/universal/node_modules/@angular/core/bundles/core.umd.js:21121:25)
  errno: -17,
  syscall: 'mkdir',
  code: 'EEXIST',
  path: '/Users/myself/projects/tools/universal/.cache' }

@meatfly
Copy link

meatfly commented Feb 20, 2019

Hi, same problem here, some hint to resolve ?

EEXIST: file already exists, mkdir '/Users/user/work/data-admin-gui/.cache'
    at mkdirSync (fs.js:775:3)
    at new FsStorageService (/Users/user/work/data-admin-gui/dist/server.js:239910:65)
    at _createClass (/Users/user/work/data-admin-gui/dist/server.js:24689:20)
    at _createProviderInstance (/Users/user/work/data-admin-gui/dist/server.js:24661:26)
    at resolveNgModuleDep (/Users/user/work/data-admin-gui/dist/server.js:24625:21)
    at NgModuleRef_.get (/Users/user/work/data-admin-gui/dist/server.js:25333:16)
    at new FsCacheService (/Users/user/work/data-admin-gui/dist/server.js:240075:35)
    at _createClass (/Users/user/work/data-admin-gui/dist/server.js:24691:20)
    at _createProviderInstance (/Users/user/work/data-admin-gui/dist/server.js:24661:26)
    at resolveNgModuleDep (/Users/user/work/data-admin-gui/dist/server.js:24625:21)

@meatfly
Copy link

meatfly commented Feb 20, 2019

there is bug in XpFsStorageService use if (!stat.isDirectory()) { not
if (!stat.hasOwnProperty('isDirectory')) {

workaround can by done by own implementation of storageService
https://gist.github.com/meatfly/baff02d8004802a870b77171f0b3f6e0

and than use in app.server.module.ts

   ServerCacheModule.forRoot([
      {
        provide: CACHE,
        useClass: FsCacheService
      },
      {
        provide: STORAGE,
        useClass: XpFsStorageService

@squelix
Copy link

squelix commented May 9, 2019

I still have this error

Error: EEXIST: file already exists, mkdir '/usr/src/app/.cache'
    at Object.mkdirSync (fs.js:752:3)
    at new XpFsStorageService (/usr/src/app/dist/server.js:4438:18)
    at _createClass (/usr/src/app/dist/server.js:90200:20)
    at _createProviderInstance (/usr/src/app/dist/server.js:90172:26)
    at resolveNgModuleDep (/usr/src/app/dist/server.js:90136:21)
    at NgModuleRef_../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (/usr/src/app/dist/server.js:90844:16)
    at new FsCacheService (/usr/src/app/dist/server.js:123492:35)
    at _createClass (/usr/src/app/dist/server.js:90202:20)
    at _createProviderInstance (/usr/src/app/dist/server.js:90172:26)
    at resolveNgModuleDep (/usr/src/app/dist/server.js:90136:21)

Event with your XpFsStorageService 😕

@fulls1z3 fulls1z3 added this to To do in ngx f.s. Jul 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
ngx f.s.
  
To do
Development

No branches or pull requests

5 participants