Skip to content

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

@logan-jobzmall

Description

@logan-jobzmall

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions