Learning Node

Errata for Learning Node

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted Date Corrected
PDF
Page n/a
Line 21

This is not errata for the book itself, but rather for the code examples. The package.json file has the following on line 21: "db-mysql":, "*", Note the comma following the colon. This should be: "db-mysql": "*", This prevents 'npm install -d' from running due to a JSON parse error in node v0.10.4

Note from the Author or Editor:
Fixed typo in example file, and uploading.

Kevin Lindsey  Apr 15, 2013 
PDF
Page p14
United Kingdom

1. Installed on Fedora. node isn't visible on the cmd line (not on $PATH). 2. Installed from source ( built same version as author) then add to PATH. 3. Biggy... if you're as daft as me. If you run. e.g. $node ex13.js & then you need to kill it before you can run another program? Otherwise you get events.js:48 throw arguments[1]; // Unhandled 'error' event ^ Error: listen EADDRINUSE at errnoException (net.js:670:11) at Array.0 (net.js:771:26) at EventEmitter._tickCallback (node.js:190:38) $ ps -ef | grep node will find the task. HTH

Note from the Author or Editor:
Thanks for note on Fedora. One of the interesting challenges associated with Node is the fact that installations across the various flavors of Unix differ. Thanks also for the heads up on me needing to remind folks they can't run two instances of a Node application on the same port at the same time. When copy edit comes around, I'll insert a note warning folks.

Dave Pawson  Jun 16, 2012 
PDF
Page 3
4th paragraph

Not the following command on the page: tar -zxf node-v0.8.2.tar.gz That is followed by the sentence: You now have a directory labeled node-v0.6.18. The version number cited in the sentence is older.

Note from the Author or Editor:
*FIXED in Atlas* On page 3, 4th paragraph, change reference to node-v0.6.18 to node-v0.8.2.

tewarid  Sep 21, 2012 
PDF
Page 7
1st paragraph

Link to https://github.com/SteveSanderson/Node-Site-Templates-for-WebMatrix is no longer correct. Location (as of April 5 2013) is https://github.com/SteveSanderson/Node.js-Site-Templates-for-WebMatrix

Note from the Author or Editor:
*edited* Modified URL in book

Simon Dismore  Apr 05, 2013 
PDF
Page 18
Example 1-4 - test harness

The code of the test harness works as printed in node 0.6 or node 0.8, but it won't work in node 0.10.0. Instead the test harness hangs after issuing 5 requests. It would appear it has hit the limit on the number of open connections at the same time, indicating that the first 5 requests have not fully completed. It seems that the connection doesn't get closed until the client code has processed the data received in the response. The code can be made to work in 0.10 (and still in 0.6 or 0.8) by changing the processPublicTimeline function to read: var processPublicTimeline = function(res) { console.log('finished request'); res.on('data', function (chunk) { }); };

Note from the Author or Editor:
*edited* Use response.resume();

John Winters  Mar 22, 2013 
PDF
Page 23
1st code snippet

_ ++ doesn't increme as shown in the code. The value stays at 2, cause with post increment the value is first returned and increased after. _ += 1 or ++ _ would produce the expected output.

Note from the Author or Editor:
*FIXED in Atlas* On page 23, code snippet that reads > a = 2; 2 > _ ++; 3 > _ ++; 4 Should be > a = 2; 2 > ++_ 3 > ++_ 4

Konstantin Bernhardt  Aug 22, 2012 
Safari Books Online
36
section "global"

All occurrences of "windows" should be replaced by "window", the proper name of the global object in a browser environment.

Note from the Author or Editor:
Page 36, the global object is window, not windows. Change.

Thomas Corbière  Sep 30, 2012 
Safari Books Online
40
3rd encoding option

"usc2" should be replaced by "ucs2".

Note from the Author or Editor:
Page 40, change to ucs2

Thomas Corbière  Sep 30, 2012 
Printed
Page 41
Last line of code fragment at top of page

In the setTimeOut function call, on_openAndReadFile should be the first function argument; there is no openAndReadFile function defined.

Note from the Author or Editor:
In code snippet page 41, correct the last line of code to read setTimeout(on_OpenAndReadFile, 2000, filename, res);

Anonymous  Nov 19, 2012 
PDF
Page 51
5th line from bottom

find.stderr.on('data', function(data) { console.log('grep stderr: ' + data); }); looks like it should be: console.log('find stderr: ' + data); ^^^^

Note from the Author or Editor:
The word grep should be changed to find

Anonymous  Mar 17, 2013 
Safari Books Online
59
8th paragraph

The statement: if (somecriteria) { en.emit('data'); } has 2 typos. To be consistent with the rest of the text, it should be: if (somecriteria) { em.emit('somevent''); } ^^^ ^^^^^^^^^^

Note from the Author or Editor:
Page 59, snippet that reads if (somecriteria) { en.emit('data'); } should read if (somecriteria) { em.emit('event'); }

Anonymous  Mar 04, 2013 
Printed
Page 64
bulleted list near the bottom of the page

There appears to be a search missing from the list: * /home/node_modules/mymodule.js The missing search should be inserted between the following two items: * /home/myname/node_modules/mymodule.js * /node_modules/mymodule.js

Note from the Author or Editor:
In list in middle of page 64, insert the line /home/node_modules/mymodule.js between /home/myname/node_modules/mymodule.js /node_modules/mymodule.js

Anonymous  Nov 19, 2012 
Safari Books Online
65
page top

"delete require.cache('./circle.js');" should be replaced by "delete require.cache['/absolute/path/to/circle.js'];" as cache is an object and the keys are the absolute path of the loaded module.

Note from the Author or Editor:
Change example on page 65 from delete require.cache('./circle.js'); to delete require.cache('/absolutepath/circle.js');

Thomas Corbière  Sep 30, 2012 
PDF
Page 83
Example 5-2

try { test.doSomething('test', 3.55, function(err,value) { if (err) throw err; console.log(value); }); } catch(err) { console.error(err); } The line: if (err) throw err; will always throw an error for anything not false. If you replace the second parameter 3.55 with a string ('this') as instructed, the first parameter will still be thrown and logged as an error. This can be verified by simply adding some text: console.error("error is: ".red + err);

Note from the Author or Editor:
Correct example 5-2 to replace the following line: callback(arg1); With the following: callback(null, arg1);

Adrian Patino  Nov 16, 2012 
Safari Books Online, Other Digital Version
Page 83
Last paragraph

The text says: "Example 5-2 is a complete Node application that creates an object with one method, someMethod", yet in the code example, the method is called "doSomething" not "someMethod".

Note from the Author or Editor:
Change the reference to the literal from someMethod to doSomething on page 83.

Ariel Ortiz  Mar 01, 2013 
ePub
Page 85
Top

Two errors in the process.nextTick example: function asynchFunction = function (data, callback) { process.nextTick(function() { callback(val); }); ); 1. `function asynchFunction` should be `var asynchFunction` 2. `callback(val);` should be `callback(data);`

Note from the Author or Editor:
In this code snippet, which I show in page 39 in Safari Online, change the code from function asynchFunction = function (data, callback) { process.nextTick(function() { callback(val); }); ); To var asynchFunction = function (data, callback) { process.nextTick(function() { callback(data); }); );

Noah J. Freitas  Dec 22, 2012 
Safari Books Online
88
page bottom

"console.log('all finished');" should be changed to "console.log('all done');" to match the output example.

Note from the Author or Editor:
*FIXED in Atlas* page 88 change the text to all finished in code snippet

Thomas Corbière  Sep 30, 2012 
Safari Books Online
94
example 5-9 caption

Shouldn't it be "Step's parallel functionality" instead of "Step's group functionality"?

Note from the Author or Editor:
*FIXED in Atlas*

Thomas Corbière  Sep 30, 2012 
Safari Books Online, Other Digital Version
Page 105
First code snippet

The first line of code is: res.setHeader('Content-Type', 'test/html'); It should be "text" not "test": res.setHeader('Content-Type', 'text/html');

Note from the Author or Editor:
Change code snippet from res.setHeader('Content-Type', 'test/html'); to res.setHeader('Content-Type', 'text/html');

Ariel Ortiz  Mar 01, 2013 
Safari Books Online
130
sidebar "Setting the Application Mode"

You should add the missing closing parentheses at the end of the two app.config() lines.

Note from the Author or Editor:
*FIXED in Atlas* Add a closing parenthesis to code snippets in sidebar that start with app.config.

Thomas Corbière  Sep 30, 2012 
Safari Books Online
208
section "Getting Started with MongoDB"

You should remove the colon in front of the port number.

Note from the Author or Editor:
*FIXED in Atlas* Remove the colon in front of the 27017 in the code snippet.

Thomas Corbière  Sep 30, 2012 
Safari Books Online
243
allowNull description

Shouldn't it be true to allow nulls instead of false?

Note from the Author or Editor:
*FIXED in Atlas* Page 243, section on allowNulls Change to true to allow nulls; true by default

Thomas Corbière  Sep 30, 2012 
Safari Books Online
250
1st paragraph

In "Or you can use always use both." remove the extraneous "use".

Note from the Author or Editor:
*FIXED in Atlas*

Thomas Corbière  Sep 30, 2012 
Safari Books Online
252
1st bullet

It reads "A form to select which PDF tool to upload" but I think you meant "A form to select which PDF document to upload", didn't you?

Note from the Author or Editor:
*FIXED in Atlas* Please change text on page 252 from A form to select which PDF tool to upload To A form to select which PDF document to upload

Thomas Corbière  Sep 30, 2012 
Safari Books Online
266
Content-Range header format

The required colon after the header name is missing. The correct format should be: Content-Range: bytes 44040192-44062881/44062882

Note from the Author or Editor:
*FIXED in Atlas* Page 266 change snippet of code from Content-Range bytes 44040192-44062881/44062882 To Content-Range: bytes 44040192-44062881/44062882

Thomas Corbière  Sep 30, 2012 
Safari Books Online
299
warning section

path.existsSync has been replaced by fs.existsSync not js.existsSync.

Note from the Author or Editor:
*FIXED in Atlas - removed warning node because Jasmine is fixed* Page 299, note, change js.existsSync to fs.existsSync

Thomas Corbière  Sep 30, 2012 
Safari Books Online
316
section titled "Setting Up TSL/SSL"

The technology is named TLS not TSL. You should replace all occurences of TSL with TLS.

Note from the Author or Editor:
Page 316, change TSL to TLS in page.

Thomas Corbière  Sep 30, 2012 
Printed
Page 320
Just after the 6th paragraph

The sql create statement does not include the 'salt' column.

Note from the Author or Editor:
Typo in the code, should be salt not salt]

None  Jun 07, 2013 
PDF
Page 329
line 14, example 15-4

Database name in USE statement inconsistent with previous USE statement. passport.deserialiseUser() on p328 uses databasenm passport.use() on p329 uses nodetest2

Note from the Author or Editor:
Page 329, code line client.query('USE nodetest2'); should read client.query('USE databasenm');

Paul Bennett  Dec 01, 2012 
ePub
Page 330
Code example - error messages upon login

The example discusses logging into an application with Passport. It returns separate error messages for user not found ("Unknown user") or invalid password ("Invalid password"). Setting your code up like that would allow an attacker to enumerate valid user id's. Login error messages must be kept identical and generic to prevent this kind of attack...

Note from the Author or Editor:
I'm assuming you're referring to SQL Injection. I don't see it in the code, but will look at it again. Regardless, the code for this functionality has changed in the Passport module since I wrote the book, so will need to change it anyway during this new update.

Mike Rice  Jul 18, 2013 
Safari Books Online
338
2nd line

The content of the name string should be "'johnsmith'; drop table users" with johnsmith properly quoted as it is a string and not a column. Without quoting, the first statement would fail and in some environment (e.g. PHP with PDO), the second statement would not be executed and the attack would be unsuccessful.

Note from the Author or Editor:
*FIXED in Atlas* Change line to 'johnsmith"; drop table users'

Thomas Corbière  Sep 30, 2012