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

Circular References (related to persitify) #5

Closed
nopnop opened this issue Jul 21, 2016 · 2 comments
Closed

Circular References (related to persitify) #5

nopnop opened this issue Jul 21, 2016 · 2 comments

Comments

@nopnop
Copy link
Contributor

nopnop commented Jul 21, 2016

Hello,

I came across a problem with persistify that is related to flat-cache (persistify is really awesome by the way)

Sometimes, browserify cache may contain circular reference that break flat-cache serialization. I fixed this by replacing JSON.stringify by json-stringify-safe in cache.js#L109. But it may not be a good solution so I won't push a PR before having your perspective on this.

Maybe for a caching mechanism, highly related to development purpose, it's acceptable to fallback to something like json-stringify-safe. At least with a warning instead of a fatal Exception or with a lenient options to optionally use json-stringify-safe instead of JSON.stringify ?

@royriojas
Copy link
Contributor

hi @nopnop,

that's interesting, I never came to a situation like that, maybe this is a chance to try https://github.com/WebReflection/circular-json. That library claims to be able to serialize circular references. might be worth.

The problem is that if we cannot recreate the cache as it is then it will be a real problem as I bet the bundle won't be useful.

If you can give it a try I'm more than happy to review/merge.

Let me know.

@nopnop
Copy link
Contributor Author

nopnop commented Jul 25, 2016

Nice, I'll give a try with https://github.com/WebReflection/circular-json
Circular dependency is usually the result of a bad-design (It could append with a require inside a function for instance). Anyway, this may appeared in third-party library.
I'll keep you up-to date

royriojas added a commit that referenced this issue Aug 1, 2016
FIX: Use circular-json to handle circular references (fix #5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants