Comments (4)
Seen when calling serveFile('/', 200, {}, req, res)
from node-static.
Cat it be an instance of the https://github.com/cloudhead/node-static/issues#issue/4 issue?
from node-static.
Yes, it is. The proposed fix in https://github.com/cloudhead/node-static/issues#issue/4 is also valid, but only for that case (wrong path). In general, you should never call finish(null, ...), because that will always result in the 'TypeError: Cannot call method 'toString' of null' error.
from node-static.
Having the same issue. This generally happens if the path is not a file but a directory. Now we COULD check for this ourselves before calling serveFile(), however, that isn't the issue. This exception crashes node since it is uncaught and cannot be caught. Now say you have a live site running and it gets crawled? /files/foo/exist.txt may work fine so the crawler decides to fetch /files/foo/ , thanks to your custom /files/ handler node-static will serve this too and crash node because it is not a file.
So as I said we COULD check for this (dir or file?) ourselves but I actually tested this to see how node-static performs in case there is ANY error accessing the file. This could be wrong / changed file permissions or any other file access error. It DOES jump into my "error" listener, so far so good. I do the
resp.writeHead(500, { 'Content-Type': 'text/plain' });
resp.end(JSON.stringify(err));
thing and it gets executed. STILL what happens next is this:
http.js:832
var statusLine = 'HTTP/1.1 ' + statusCode.toString() + ' ' +
^
TypeError: Cannot call method 'toString' of null
at ServerResponse.writeHead (http.js:832:45)
at [object Object].finish (/home/foo/bar/node_modules/node-static.js:108:17)
at /home/foo/bar/node_modules/node-static.js:87:18
at /home/foo/bar/node_modules/node-static.js:215:33
at [object Object]. (/home/foo/bar/node_modules/node-static.js:245:17)
at [object Object].emit (events.js:64:17)
at afterRead (fs.js:858:12)
@cloudhead I have no problem fixing this myself for my local 0.5.3 for now but will this be fixed "officially" for 0.5.4 too? I'm sure it's just a one-line check-for-null/undefined... fingers crossed.
from node-static.
Related Issues (20)
- Publish latest version to npm HOT 5
- Hidden files/folders HOT 4
- "Range request exceeds file boundaries" in console HOT 2
- Version in Server header is still 0.7.9
- How do I set headers? HOT 2
- Error when processing range request using Chrome
- Replace optimist or otherwise avoid its vulnerability HOT 8
- Post parameters HOT 1
- setTimeout not working? Can't throttle server...
- Security vulnerabilities HOT 2
- New fork resolving vulnerabilities and incorporating most current PRs HOT 33
- neodoc is a massive dependency HOT 4
- Publish New NPM version for Node-Static HOT 12
- Switch optimist to minimalist (dev-dependency) HOT 1
- Why this version? HOT 2
- Error: Class constructor Server cannot be invoked without 'new' HOT 2
- 404 page
- Update to latest mime-db, to send "text/javascript" MIME type for ".js" / ".mjs" files?
- [ERR_HTTP_HEADERS_SENT] after successfully requesting a file with "Range: bytes=0-" HOT 2
- low performance
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-static.