Skip to content

[email protected] breaks build ⚠️ - #5438

Closed
greenkeeperio-bot wants to merge 1 commit into
masterfrom
greenkeeper-lodash-4.5.0
Closed

greenkeeperio-bot wants to merge 1 commit into
masterfrom
greenkeeper-lodash-4.5.0

Conversation

@greenkeeperio-bot

Copy link
Copy Markdown
Contributor

Hello 👋

⚠️⚠️⚠️

lodash just published its new version 4.5.0, which is covered by your current version range. After updating it in your project the build kept failing.

This means it’s possible that your software is malfunctioning, because of this update. Use this branch to work on adaptions and fixes.

Happy fixing and merging 🌴


This pull request was created by greenkeeper.io.
It keeps your software, up to date, all the time.

Tired of seeing this sponsor message? Upgrade to the supporter plan! You'll also get your pull requests faster ⚡

@janmeier

Copy link
Copy Markdown
Member

So, I've been working a bit on upgrading lodash to 4.5 - nothing to commit yet though. The problem is this commit - which fixes an actual bug in lodash, but introduces problems for us.

Basically it clones objects before merging them, as evidenced by #5476, where lodash is trying to clone properties of the pg module, because its cloning the User object, which has a reference to pg.

We've had similar issues before, which is why we have a specialized function for cloning options objects which avoids cloning sequelize models / instances. However, this time the problem is with merge (which calls clone), not with us calling clone directly. Using mergeWith is not a fantastic solution either, because we would have to implement all the merge logic ourselves to avoid the cloning.

Not really sure how to proceed here - perhaps we could somehow tell lodash not to clone certain sequelize objects (although that feels kinda dirty)

@jdalton

jdalton commented Feb 23, 2016

Copy link
Copy Markdown

The _.mergeWith method allows you to customize the bits you need and defer to the built-in behavior when needed. If the customizer returns undefined the merge is handled by lodash otherwise it's handled by the customizer.

Do you know what's the issue with the clone is it missing some initialization?

@janmeier

Copy link
Copy Markdown
Member

Re. mergeWith - Yes, but as soon as we defer something to lodash, the object is deeply cloned. E.g.
{ defaultScope: { include: [User] }}, where User is an instance of sequelize.Model. When the customizer sees a POJO (the model is deeply nested) it returns undefined, which makes lodash clone the whole object, including the user. In order to prevent cloning the user model the customizer would have to traverse the object and implement the merge itself.

I'm not saying this is wrong, its just unfortunate for us, for two reasons:

  1. Models have a reference to the lib which they use to connect to the DB. node-pg has a lazy-loaded getter native, which is invoked by lodash's clone - but on systems where the native library is not compiled (systems without libpq-dev or similar) this will throw an error, pg-native incorrectly accessed for lodash@^4.4.0 #5476.
  2. Some of our unit tests (fx this one) previously used strict equality to verify that models were equal. Now that models are cloned, strict equality cannot be used, so chai falls back to recursively checking equality - which ends in an out of memory error, probably because of infinite recursion caused by circular references (which chai is not smart enough to figure out). This point is less important, since it can be fixed by using _.isEqual

@jdalton

jdalton commented Feb 24, 2016

Copy link
Copy Markdown

Lodash doesn't really support getters. Looks like this was a trap waiting to be hit.
If you don't want the native property iterated you should make it non-enumerable.

@janmeier

Copy link
Copy Markdown
Member

Yep, I've contacted brianc with regards to marking the native property as non-enumerable, brianc/node-postgres#945

Thanks @jdalton

@jdalton

jdalton commented Feb 24, 2016

Copy link
Copy Markdown

Awesome!

@janmeier janmeier closed this Apr 2, 2016
@janmeier
janmeier deleted the greenkeeper-lodash-4.5.0 branch April 2, 2016 20:13
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

Successfully merging this pull request may close these issues.

3 participants