kitajchuk / node-squarespace-server

DEPRECATED! A local Squarespace development server in node.js.
MIT License
186 stars 26 forks source link

Server crashes when file doesn't exist #174

Closed derekduoba closed 8 years ago

derekduoba commented 8 years ago

Earlier today, I found an issue where the NodeSquarespace server will crash if a file within the "assets" directory does not exist (or, in my case, is improperly named). I attempted to add the following into the of site.region:

Unfortunately, I spelled it incorrectly:

The server crashed almost immediately upon issuing "sqs server --reload." Once I commented out the offending , the server was able to start without issue.

Next, I attempted to access the asset in question at the incorrectly-spelled URL:

http://localhost:5050/assets/**phtotoswipe**/default-skin.css

This caused the server to crash and throw the same error as before. Relevant stack trace below:

sqs-log Get local cache for key => page-assets-phtotoswipe-photoswipe.cs.html sqs-log Get local cache for key => page-assets-phtotoswipe-photoswipe.cs.json sqs-log Store local cache for key => page-assets-phtotoswipe-photoswipe.cs.json sqs-log Store local cache for key => page-assets-phtotoswipe-photoswipe.cs.html sqs-log Get local cache for key => page-assets-phtotoswipe-photoswipe.cs.html /usr/local/lib/node_modules/node-squarespace-server/squarespace-template.js:897 typeName = pageJson.collection.typeName; ^

TypeError: Cannot read property 'typeName' of undefined at getTemplateKey (/usr/local/lib/node_modules/node-squarespace-server/squarespace-template.js:897:35) at Object.renderTemplate (/usr/local/lib/node_modules/node-squarespace-server/squarespace-template.js:446:23) at /usr/local/lib/node_modules/node-squarespace-server/squarespace-server.js:263:29 at /usr/local/lib/node_modules/node-squarespace-server/node_modules/node-squarespace-middleware/squarespace-middleware.js:376:13 at Request._callback (/usr/local/lib/node_modules/node-squarespace-server/node_modules/node-squarespace-middleware/squarespace-middleware.js:300:9) at Request.self.callback (/usr/local/lib/node_modules/node-squarespace-server/node_modules/request/request.js:199:22) at emitTwo (events.js:100:13) at Request.emit (events.js:185:7) at Request. (/usr/local/lib/node_modules/node-squarespace-server/node_modules/request/request.js:1036:10) at emitOne (events.js:95:20)

kitajchuk commented 8 years ago

Yeah, it should ideally not do this, but its just serving the template directory as a static dir through express, so it is relying on order of operations for URLs. I haven't looked into a resolve for this yet other than make sure you're not referencing assets that don't exist :/