Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Buffer error message should not dump buffer's memory contents #1975

Closed
nalply opened this issue Oct 31, 2011 · 1 comment
Closed

Buffer error message should not dump buffer's memory contents #1975

nalply opened this issue Oct 31, 2011 · 1 comment
Labels

Comments

@nalply
Copy link

nalply commented Oct 31, 2011

nalp@muse:~/mtrude$ node -v; node -e '(new Buffer(10).x())'
v0.5.10

undefined:1
*
^
TypeError: Object ��R���R4 has no method 'x'
    at Object.<anonymous> (eval at <anonymous> (eval:1:75))
    at Object.<anonymous> (eval:1:63)
    at Module._compile (module.js:432:26)
    at startup (node.js:84:14)
    at node.js:534:3

Expected behavior:

undefined:1
*
^
TypeError: Buffer has no method 'x'
    at Object.<anonymous> (eval at <anonymous> (eval:1:75))
    at Object.<anonymous> (eval:1:63)
    at Module._compile (module.js:432:26)
    at startup (node.js:84:14)
    at node.js:534:3

Note! It is even worse for new Buffer(1000) or even new Buffer(1024 * 1024)... Also

node -e 'b = new Buffer(5); b[0] = 27; b[1] = 91; b[2] = 51; b[3] = 50; b[4] = 109; b.x()'

paints the rest of the stack trace green.

@bnoordhuis
Copy link
Member

There's not much Node can do about that. The TypeError is generated by V8 and it calls .toString() on the object when it generates the error message. Point in case (snipped for brevity):

> {toString: function() { return "BAM" }}.g()
TypeError: Object BAM has no method 'g'
    at repl:1:42
> function F(){} F.prototype.toString = function() { return "BAM" }; (new F).g();
TypeError: Object BAM has no method 'g'
    at repl:1:76

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants