Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Not Found #1

Closed
sefinek24 opened this issue Jul 15, 2023 · 21 comments
Closed

Error: Not Found #1

sefinek24 opened this issue Jul 15, 2023 · 21 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers under correction the bug is being fixed

Comments

@sefinek24
Copy link

I receive sometimes an error:

0|blocklist  | 05:44:27.847 15.07.2023: Error: Not Found
0|blocklist  |     at n.error (/home/ubuntu/node/www/Sefinek-Blocklist-Collection/node_modules/express-autoindex/dist/index.cjs.js:1:1793)
0|blocklist  |     at /home/ubuntu/node/www/Sefinek-Blocklist-Collection/node_modules/express-autoindex/dist/index.cjs.js:1:2327

can it be fixed? Please

@c-bertran
Copy link
Owner

c-bertran commented Jul 15, 2023 via email

@sefinek24
Copy link
Author

sefinek24 commented Jul 15, 2023

Thanks for your answer

When does this error occur?

(polish timezone)

0|blocklis | 14:56:40.356 15.07.2023: Error: Not Found
0|blocklis |     at n.error (/home/ubuntu/node/www/Sefinek-Blocklist-Collection/node_modules/express-autoindex/dist/index.cjs.js:1:1793)
0|blocklis |     at /home/ubuntu/node/www/Sefinek-Blocklist-Collection/node_modules/express-autoindex/dist/index.cjs.js:1:2327
0|blocklis | 14:57:05.359 15.07.2023: Error: Not Found
0|blocklis |     at n.error (/home/ubuntu/node/www/Sefinek-Blocklist-Collection/node_modules/express-autoindex/dist/index.cjs.js:1:1793)
0|blocklis |     at /home/ubuntu/node/www/Sefinek-Blocklist-Collection/node_modules/express-autoindex/dist/index.cjs.js:1:2327
0|blocklis | 15:00:52.321 15.07.2023: Error: Not Found
0|blocklis |     at n.error (/home/ubuntu/node/www/Sefinek-Blocklist-Collection/node_modules/express-autoindex/dist/index.cjs.js:1:1793)
0|blocklis |     at /home/ubuntu/node/www/Sefinek-Blocklist-Collection/node_modules/express-autoindex/dist/index.cjs.js:1:2327
0|blocklis | 15:11:17.795 15.07.2023: Error: Not Found
0|blocklis |     at n.error (/home/ubuntu/node/www/Sefinek-Blocklist-Collection/node_modules/express-autoindex/dist/index.cjs.js:1:1793)
0|blocklis |     at /home/ubuntu/node/www/Sefinek-Blocklist-Collection/node_modules/express-autoindex/dist/index.cjs.js:1:2327
0|blocklis | 15:21:46.046 15.07.2023: Error: Not Found
0|blocklis |     at n.error (/home/ubuntu/node/www/Sefinek-Blocklist-Collection/node_modules/express-autoindex/dist/index.cjs.js:1:1793)
0|blocklis |     at /home/ubuntu/node/www/Sefinek-Blocklist-Collection/node_modules/express-autoindex/dist/index.cjs.js:1:2327

Every few minutes, this error appears when the client sends GET requests to statically served files.

Is the error regularly obtained or not?

Yes

My source code:
https://github.com/sefinek24/Sefinek-Blocklist-Collection/blob/ce6c9bc5b48da66f66e53f36e9ace10302637515/server.js#L44
https://github.com/sefinek24/Sefinek-Blocklist-Collection/blob/ce6c9bc5b48da66f66e53f36e9ace10302637515/server.js#L45

@c-bertran
Copy link
Owner

c-bertran commented Jul 15, 2023 via email

@sefinek24
Copy link
Author

sefinek24 commented Jul 15, 2023

Thank you @c-bertran, it would be great to eliminate this error as the requests ultimately end up with a 500 error.

0|blocklist  | 16:00:46.956 15.07.2023: [500 GET 2.518 ms] /generated/0.0.0.0/malicious-sites.txt - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36
0|blocklist  | 16:00:46.982 15.07.2023: Error: Not Found
0|blocklist  |     at n.error (/home/ubuntu/node/www/Sefinek-Blocklist-Collection/node_modules/express-autoindex/dist/index.cjs.js:1:1793)
0|blocklist  |     at /home/ubuntu/node/www/Sefinek-Blocklist-Collection/node_modules/express-autoindex/dist/index.cjs.js:1:2327
0

@c-bertran c-bertran added the bug Something isn't working label Jul 16, 2023
@c-bertran c-bertran self-assigned this Jul 16, 2023
@c-bertran
Copy link
Owner

c-bertran commented Jul 16, 2023

I've just gone through the whole code again.
I've decided to implement a much more advanced error handling system than the original one. Depending on the type of error, the status code of the response is set to a specific code. Non-existent files or folders now point to 404 errors regardless of type. Other error code are possible but are much rarer.
I've also decided to add more information to the error output if the environment is not in production.

The new version is 1.1.1

I've tried this on several fairly brutal unit tests and I can't get this bug anymore. Nevertheless, if it comes back from your side, I'll keep on correcting the bug based on your source code directly.

Thank you again for trusting me and for your patience.

@c-bertran
Copy link
Owner

c-bertran commented Jul 17, 2023

I've just reworked the error handling a bit, and the most important thing is to explain how it's handled in the README.

I've also added the production mode, which makes it possible to have error messages that are much less explanatory for security reasons, and vice versa.

Is it now working properly on your side @sefinek24 ?

@c-bertran c-bertran added good first issue Good for newcomers under correction the bug is being fixed labels Jul 17, 2023
@sefinek24
Copy link
Author

sefinek24 commented Jul 19, 2023

I'll check this today,
Sorry for the long wait for a response

@sefinek24
Copy link
Author

sefinek24 commented Jul 19, 2023

Hello again @c-bertran. I've checked the latest version, and from now on, every request to a non-existing static file results in a 500 error. Could you please fix this? Or provide an option to disable it?

0|blocklist  | 19:26:34.833 19.07.2023: [500 GET 1.123 ms] /generated/example - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
0|blocklist  | 19:26:34.839 19.07.2023: Error: No such file or directory
0|blocklist  | → (ENOENT: no such file or directory, stat '/home/ubuntu/node/www/Sefinek-Blocklist-Collection/blocklist/generated/example')
0|blocklist  |     at o.error (/home/ubuntu/node/www/Sefinek-Blocklist-Collection/node_modules/express-autoindex/dist/index.cjs.js:1:2864)
0|blocklist  |     at /home/ubuntu/node/www/Sefinek-Blocklist-Collection/node_modules/express-autoindex/dist/index.cjs.js:1:3502
0|blocklist  | 19:28:14.479 19.07.2023: [200 GET 1.682 ms] /generated/0.0.0.0/forks/neodevpro.neodevhost.txt - Go-http-client/1.1

@c-bertran
Copy link
Owner

It's really strange, in my case it's 404 requests that come out, not 500. I'll run the tests again in an hour when I get home from work.
I'll try my unit tests on your project.

@c-bertran c-bertran reopened this Jul 19, 2023
@sefinek24
Copy link
Author

Okay no problem 👍 (:

@sefinek24
Copy link
Author

f6a3b518a1c3152911b4808411a3be5e

@c-bertran
Copy link
Owner

I was busy with my company, so I couldn't reply first.

I've modified the code to be even closer to Node's errors, and after a lot of testing, especially on node_modules of several GB and under Debian, Windows 11 and MacOs 13, non-existent files and folders always return a 404.
I'll be releasing the patched version in a few minutes, so let me know if the error persists.

@c-bertran
Copy link
Owner

The new version 1.1.3 is out, and if the error persists, I honestly can't understand it.

@sefinek24
Copy link
Author

something went wrong >:

PS C:\GitHub\Sefinek-Blocklist-Collection> node .
App listening at http://127.0.0.1:5916
MongoDB connected successfully!
Connected to the database
[200 GET 33.299 ms] / - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[200 GET 3.242 ms] /css/style.css - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[404 GET 8.686 ms] /favicon.ico - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[200 GET 3.359 ms] /generated - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[404 GET 7.578 ms] /generatedg - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[404 GET 9.170 ms] /generatedg - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[304 GET 2.148 ms] /generated - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[200 GET 3.414 ms] /generated/noip - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[200 GET 2.319 ms] /generated/noip/apps - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[500 GET 1.863 ms] /generated/noip/apps/example - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
Error: No such file or directory
→ (ENOENT: no such file or directory, stat 'C:\GitHub\Sefinek-Blocklist-Collection\blocklist\generated\noip\apps\example')
    at o.error (C:\GitHub\Sefinek-Blocklist-Collection\node_modules\express-autoindex\dist\index.cjs.js:1:3695)
    at C:\GitHub\Sefinek-Blocklist-Collection\node_modules\express-autoindex\dist\index.cjs.js:1:4333
[500 GET 0.982 ms] /generated/noip/apps/example - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
Error: No such file or directory
→ (ENOENT: no such file or directory, stat 'C:\GitHub\Sefinek-Blocklist-Collection\blocklist\generated\noip\apps\example')
    at o.error (C:\GitHub\Sefinek-Blocklist-Collection\node_modules\express-autoindex\dist\index.cjs.js:1:3695)
    at C:\GitHub\Sefinek-Blocklist-Collection\node_modules\express-autoindex\dist\index.cjs.js:1:4333
[304 GET 1.511 ms] /generated - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[304 GET 1.353 ms] /generated - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[404 GET 7.067 ms] /generatedtestt - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[404 GET 6.487 ms] /generatedtestt/test1/1 - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[404 GET 6.615 ms] /generatedtestt/test1/1/1/1/1/1/1/1 - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[404 GET 7.538 ms] /generatedtestt/test1/1/1/1/1/1/1/exampleeeeeeee - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[200 GET 21.428 ms] / - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[304 GET 0.825 ms] /css/style.css - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[304 GET 1.481 ms] /generated - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[200 GET 3.922 ms] /generated/127.0.0.1 - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[200 GET 2.285 ms] /generated/127.0.0.1/ads - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[500 GET 0.788 ms] /generated/127.0.0.1/ads/example - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
Error: No such file or directory
→ (ENOENT: no such file or directory, stat 'C:\GitHub\Sefinek-Blocklist-Collection\blocklist\generated\127.0.0.1\ads\example')
    at o.error (C:\GitHub\Sefinek-Blocklist-Collection\node_modules\express-autoindex\dist\index.cjs.js:1:3695)
    at C:\GitHub\Sefinek-Blocklist-Collection\node_modules\express-autoindex\dist\index.cjs.js:1:4333
[500 GET 0.673 ms] /generated/127.0.0.1/ads/example.txt - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
Error: No such file or directory
→ (ENOENT: no such file or directory, stat 'C:\GitHub\Sefinek-Blocklist-Collection\blocklist\generated\127.0.0.1\ads\example.txt')
    at o.error (C:\GitHub\Sefinek-Blocklist-Collection\node_modules\express-autoindex\dist\index.cjs.js:1:3695)
    at C:\GitHub\Sefinek-Blocklist-Collection\node_modules\express-autoindex\dist\index.cjs.js:1:4333
[200 GET 1.705 ms] /generated/127.0.0.1/ads/ - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
[500 GET 0.917 ms] /generated/ddd - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
Error: No such file or directory
→ (ENOENT: no such file or directory, stat 'C:\GitHub\Sefinek-Blocklist-Collection\blocklist\generated\ddd')
    at o.error (C:\GitHub\Sefinek-Blocklist-Collection\node_modules\express-autoindex\dist\index.cjs.js:1:3695)
    at C:\GitHub\Sefinek-Blocklist-Collection\node_modules\express-autoindex\dist\index.cjs.js:1:4333
[500 GET 0.875 ms] /generated/11/111 - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
Error: No such file or directory
→ (ENOENT: no such file or directory, stat 'C:\GitHub\Sefinek-Blocklist-Collection\blocklist\generated\11\111')
    at o.error (C:\GitHub\Sefinek-Blocklist-Collection\node_modules\express-autoindex\dist\index.cjs.js:1:3695)
    at C:\GitHub\Sefinek-Blocklist-Collection\node_modules\express-autoindex\dist\index.cjs.js:1:4333

@c-bertran
Copy link
Owner

To understand the bug I'm going to need your code

@sefinek24
Copy link
Author

@c-bertran
Copy link
Owner

thank you, I'll need a few hours to debug.

@c-bertran
Copy link
Owner

I've just found the origin of the bug, it's pretty tricky but correctable. I'm going to take advantage of this as I'm going to modify several things to add the possibility of creating your own page template.

@c-bertran
Copy link
Owner

c-bertran commented Jul 21, 2023

I've just released version 1.3.0 of the lib @sefinek24 .
The bug should be fixed, and I've added the ability to create your own HTML page, custom Date format and JSON object.
I've also added another option for 4xx errors to throw an error, which may be useful in certain very specific cases.

I hope this time it will be good ^^

@sefinek24
Copy link
Author

sefinek24 commented Jul 21, 2023

Thank you @c-bertran for your effort put into fixing this. I really appreciate it and thank you. Error 500 has been fixed, but unfortunately, a few new errors have appeared now.

  1. In the express-autoindex@^1.3.0 version, the character encoding for static files has stopped working correctly.

test.txt file encoding: UTF-8 without BOM

  1. Endpoints like /xxx/yyy/zzz/generated do not work with express-autoindex, even though they are correctly served statically.

Thank you also for adding the customTemplate option! There is no other npm module like yours, so I plan to use it anyway - even if it doesn't work perfectly 100%.

@c-bertran
Copy link
Owner

First of all, this is excellent news for 500 errors.
For the encoding errors I think I know why, it will take me a little time to correct the encoding errors are always longer.

As for the endpoints, I'll get to them as a matter of urgency - they're a pretty annoying bug.

I'm going to close this issue, I've opened one on new errors.

Thanks again for your patience

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers under correction the bug is being fixed
Projects
None yet
Development

No branches or pull requests

2 participants