Created
July 14, 2010 12:12
-
-
Save nickstenning/475340 to your computer and use it in GitHub Desktop.
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
| var fs = require('fs'), | |
| sys = require('sys'); | |
| fs.writeFileSync('foo-sync', '', 'utf8'); | |
| try { | |
| fs.writeFile('foo-async', '', 'utf8', function (err) { | |
| if (err) sys.puts("callback caught: " + sys.inspect(err)); | |
| }); | |
| } catch(e) { | |
| sys.puts("try/catch caught: " + sys.inspect(e)); | |
| } | |
| // Expected behaviour | |
| // Create two files, throwing no errors. Or at the very least, if an error is thrown, it should be | |
| // catchable by one of the two methods shown above -- presumably the callback method. | |
| // | |
| // Actual behaviour | |
| // Two files are indeed created, but the following error is thrown, and is uncatchable: | |
| // | |
| // buffer:60 | |
| // return this.utf8Write(string, offset); | |
| // ^ | |
| // TypeError: Offset is out of bounds | |
| // at Buffer.write (buffer:60:19) | |
| // at fs:387:52 | |
| // at node.js:255:9 | |
| // | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment