coreh-deprecated / nide

Beautiful IDE for Node.js
http://coreh.github.com/nide/
713 stars 111 forks source link

When try to open a psd file the server get down. #15

Closed hugodias closed 12 years ago

hugodias commented 12 years ago

Unintentionally clicked to open a PSD file in the editor and the server crashed with the following message: "FATAL ERROR: JS Allocation failed - process out of memory". A good idea would be to throw this exception

coreh commented 12 years ago

Hey Hugo,

That's because the PSD file was probably too large for Node.JS to handle. Node is based on Chrome's V8, and its memory model currently limits the JS heap size to about 1GB.

Google's aware of this, but it's not a high priority fix for them since V8's main application is for desktop browsing. See this: http://code.google.com/p/v8/issues/detail?id=847

Anyway, It's probably wise to check a file for its size before opening. Even if we can allocate enough memory, the way Nide currently works restricts the practical file size to a few kilobytes, since:

It should be a simple patch to this function: https://github.com/Coreh/nide/blob/master/server/project.js#L283

hugodias commented 12 years ago

Or maybe test the file extension before this line : https://github.com/Coreh/nide/blob/master/server/project.js#L290

coreh commented 12 years ago

Yeah. Perhaps we could even add specific behavior for PNG, JPEG, GIF and SVG files. (Send the file to the client encoded in a data: URL for display)

coreh commented 12 years ago

Hey @hugodias,

Nide will now refuse to open any file over 1MB in size, and will display an error message when you try to do so.

I'm marking this one as closed.

hugodias commented 12 years ago

Awesome!