You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That doesn't seem useful, so passing a function in is most likely a programmers error, so we could throw errors on that to indicate those early. Thoughts?
If there are no immediate objections, I'll make a draft PR.
@cjihrig Um, there was no reason to close your PR if you already drafted that! Less work for me =).
I have not yet started doing anything, just wanted to collect initial feedback, so if you already have a PR, it would make sense reopening it, I think?
The PR looks good at the first glance, I will review it later if you reopen it. 😉
@ChALkeR currently symbols cause an maximum call stack size error and the error message for numbers is different than from the other primitives (and less helpful).
For bigint and booleans it's only about executing less code. Currently we try to create something useful from those types and if that fails, we'll throw the error.
./node -e 'Buffer.from(Symbol())'
RangeError: Maximum call stack size exceeded
at Symbol.get [Symbol.toStringTag] (<anonymous>)
at internal/util/types.js:11:32
at isUint8Array (internal/util/types.js:29:10)
at fromObject (buffer.js:390:7)
at Function.from (buffer.js:217:13)
at Function.from (buffer.js:222:19)
at Function.from (buffer.js:222:19)
./node -e 'Buffer.from(5)'
TypeError [ERR_INVALID_ARG_TYPE]: The "value" argument must not be of type number. Received type number
at Function.from (buffer.js:210:11)
at [eval]:1:8
at Script.runInThisContext (vm.js:124:20)
at Object.runInThisContext (vm.js:314:38)
at Object.<anonymous> ([eval]-wrapper:9:26)
at Module._compile (internal/modules/cjs/loader.js:813:30)
at evalScript (internal/process/execution.js:60:25)
at internal/main/eval_string.js:16:1
Activity
devsnek commentedon Mar 18, 2019
sgtm
cjihrig commentedon Mar 18, 2019
#26743
cjihrig commentedon Mar 18, 2019
Sorry @ChALkeR. I didn't read the entire issue after I saw how to reproduce it. I'll close my PR.
BridgeAR commentedon Mar 18, 2019
@ChALkeR to me it seems like we should also throw on all primitives besides strings. That would also simplify the logic:
ChALkeR commentedon Mar 18, 2019
@cjihrig Um, there was no reason to close your PR if you already drafted that! Less work for me =).
I have not yet started doing anything, just wanted to collect initial feedback, so if you already have a PR, it would make sense reopening it, I think?
The PR looks good at the first glance, I will review it later if you reopen it. 😉
ChALkeR commentedon Mar 18, 2019
@BridgeAR could you give a list of examples which behavior get changed by that?
BridgeAR commentedon Mar 18, 2019
@ChALkeR currently symbols cause an maximum call stack size error and the error message for numbers is different than from the other primitives (and less helpful).
For bigint and booleans it's only about executing less code. Currently we try to create something useful from those types and if that fails, we'll throw the error.
BridgeAR commentedon Mar 18, 2019
buffer: use stricter `from()` input validation
buffer: use stricter `from()` input validation
buffer: use stricter `from()` input validation