metarhia/impress

Error processing url in static directory

turone opened this issue · 4 comments

turone commented

https://github.com/metarhia/impress/blob/0c4bf3b317deb5ba00c5d732028bb25a70f8a600/lib/static.js#L69C7-L69C7

I created a directory "img" in the static directory, added pictures there. But the file index.html did not create. When i navigate to the \img\ url, the browser waits for the page indefinitely. On the node server it gives an error:

07:52:22 W1 error unhandledRejection: RangeError [ERR_OUT_OF_RANGE]:
The value of "end" is out of range. It must be >= 0 && <= 9007199254740991. Received -1
new ReadStream (node:internal/fs/streams:201:5)
Object.createReadStream (node:fs:3060:10)
Static.serve (\node_modules\impress\lib\static.js:76:32)

in line 69 there is a constant "size" it is equal to 0 in this case. Accordingly, the constant "end" in line 71 is equal to -1

Can reproduce only on empty folder

Fixed in #1897

turone commented

Can reproduce only on empty folder

maybe node.fsp.stat for Windows returns a different size for a non-empty folder, unlike Linux. I tested for Windows.

No, you can see solution here #1897 size = 0 just because it is a stat of empty folder, not a file, @turone