This repository has been archived by the owner on Mar 8, 2023. It is now read-only.
fix(loader): use isPlainObject when merging. #68
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Earlier this week, one of my modules, the openshift-rest-client, which is built on top of the kubernetes-client, started to break when uploading a binary file. Basically, we create a readStream from a local file using
fs.createReadStream
which gets added to the request bodyThe error was happening in the Request module, at the point where it looks to set the ContentLength, which is should skip over if the body is a stream. Code link for reference: https://github.com/request/request/blob/3c0cddc7c8eb60b470e9519da85896ed7ee0081e/request.js#L441
The problem started happening when we upgraded to [email protected], and after some digging i noticed that the merge libraries where swapped. Since deepmerge by default clones every object property, it was "stripping" the fact that the object i passed in was a ReadStream
according to the docs, https://www.npmjs.com/package/deepmerge#ismergeableobject , that can be fixed using the "isPlainObject" module when doing merges.
This PR adds the
isPlainObject
module and also adds that third parameter to the merge function calls.I create a repo where i was basically simulating what was happening to show the difference: https://github.com/lholmquist/merge-deep-merge-fu