Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 509
Fix conversion of Uint8Array to object (#761) #762
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
Open
Maia-Everett
wants to merge
1
commit into
node-config:master
Choose a base branch
from
Maia-Everett:uint8array
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+58
−3
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| var requireUncached = require('./_utils/requireUncached'); | ||
| require('../parser'); | ||
|
|
||
| 'use strict'; | ||
|
|
||
| var vows = require('vows'), | ||
| assert = require('assert'); | ||
|
|
||
| vows.describe('Tests for parsing binary data') | ||
| .addBatch({ | ||
| 'Using the YAML parser - Uint8Array': { | ||
| topic: function() { | ||
| process.env.NODE_CONFIG_DIR = __dirname + '/22-binary'; | ||
| return requireUncached(__dirname + '/../lib/config'); | ||
| }, | ||
| 'reading !!binary returns a real Uint8Array': function(CONFIG) { | ||
| assert.deepStrictEqual(CONFIG.get('auth'), { | ||
| secret: new Uint8Array([0x10, 0x11, 0x12, 0x13, 0x14, 0x15]) | ||
| }); | ||
| }, | ||
| } | ||
| }) | ||
| .export(module); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| auth: | ||
| secret: !!binary 'EBESExQV' |
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.
You can’t perform that action at this time.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to be clear that I'm not trying to shoot the messenger here.
This function is a mess. And every case we add to it makes it more obvious to me that it's a mess.
It's a bad copy of cloneDeep, and I'm encountering places where we are recursing objects we should not be recursing. I think this needs a rethink. I'm trying to write a benchmark loop right now to make sure I'm not introducing regressions, and it's breaking because somehow we've gotten past the Buffer guard at the top of the function and now I'm getting errors from the TypedArray inside the Buffer. So there's that.
I just discovered the other day that the reason
makeImmutable()couldn't be moved to Util is actually false coupling. So I think it can be moved, leaving the one, intrusive backward compatibility feature in config.util (and deprecating it) and rearrange this mess to look more like cloneDeep, which it should in fact be a sibling to and so very much isn't. Probably because different people have cared about different bugs in each.I have enough open PRs at the moment, with two more in the chamber, so I won't be tackling that right now but for sure that's on the roadmap now.