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

/file with do_minify=false, fix reply already sent errors #49

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

mreishus
Copy link
Contributor

@mreishus mreishus commented Jan 24, 2025

When hitting a url like http://localhost:4747/file?path=dashicons.css, which sets do_minify=false, fastify is spamming the console with several "reply already sent" errors. The "don't minify" paths need to return after sending a response to fix this.

Example:

{"level":30,"time":1737734244837,"pid":62861,"hostname":"local.local","reqId":"req-2","req":{"method":"GET","url":"/file?path=dashicons.css","host":"localhost:4747","remoteAddress":"127.0.0.1","remotePort":63842},"msg":"incoming request"}
{"path":"./minifiers/dashicons.css","minify":false,"when":"2025-01-24T15:57:24.838Z"}
{"path":"./minifiers/dashicons.css","minify":false,"when":"2025-01-24T15:57:24.843Z","original_size":105,"minify_ms":2,"type":"css","minify_size":25,"minify_size_diff":80,"minify_size_diff_percent":76,"compress_ms":1,"compress_size":31,"compress_size_diff":-6,"compress_size_diff_percent":-24}
{"path":"./minifiers/dashicons.css","minify":false,"when":"2025-01-24T15:57:24.844Z","original_size":105,"minify_ms":2,"type":"css","minify_size":25,"minify_size_diff":80,"minify_size_diff_percent":76,"compress_ms":1,"compress_size":31,"compress_size_diff":-6,"compress_size_diff_percent":-24,"cache":"no"}
{"path":"./minifiers/dashicons.css","minify":false,"when":"2025-01-24T15:57:24.847Z","original_size":105,"minify_ms":1,"type":"css","minify_size":25,"minify_size_diff":80,"minify_size_diff_percent":76,"compress_ms":0,"compress_size":31,"compress_size_diff":-6,"compress_size_diff_percent":-24,"cache":"no"}
{"level":30,"time":1737734244842,"pid":62861,"hostname":"local.local","reqId":"req-2","res":{"statusCode":200},"responseTime":4.597749948501587,"msg":"request completed"}
{"level":40,"time":1737734244843,"pid":62861,"hostname":"local.local","reqId":"req-2","err":{"type":"FastifyError","message":"Reply was already sent, did you forget to \"return reply\" in \"/file?path=dashicons.css\" (GET)?","stack":"FastifyError: Reply was already sent, did you forget to \"return reply\" in \"/file?path=dashicons.css\" (GET)?\n    at Reply.send (./minifiers/node_modules/fastify/lib/reply.js:132:26)\n    at send_reply (./minifiers/routes/file.js:180:9)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async module.exports (./minifiers/routes/file.js:65:4)","code":"FST_ERR_REP_ALREADY_SENT","name":"FastifyError","statusCode":500},"msg":"Reply was already sent, did you forget to \"return reply\" in \"/file?path=dashicons.css\" (GET)?"}
{"level":40,"time":1737734244845,"pid":62861,"hostname":"local.local","reqId":"req-2","err":{"type":"FastifyError","message":"Reply was already sent, did you forget to \"return reply\" in \"/file?path=dashicons.css\" (GET)?","stack":"FastifyError: Reply was already sent, did you forget to \"return reply\" in \"/file?path=dashicons.css\" (GET)?\n    at Reply.send (./minifiers/node_modules/fastify/lib/reply.js:132:26)\n    at send_reply (./minifiers/routes/file.js:120:10)\n    at module.exports (./minifiers/routes/file.js:95:9)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","code":"FST_ERR_REP_ALREADY_SENT","name":"FastifyError","statusCode":500},"msg":"Reply was already sent, did you forget to \"return reply\" in \"/file?path=dashicons.css\" (GET)?"}
{"level":40,"time":1737734244847,"pid":62861,"hostname":"local.local","reqId":"req-2","err":{"type":"FastifyError","message":"Reply was already sent, did you forget to \"return reply\" in \"/file?path=dashicons.css\" (GET)?","stack":"FastifyError: Reply was already sent, did you forget to \"return reply\" in \"/file?path=dashicons.css\" (GET)?\n    at Reply.send (./minifiers/node_modules/fastify/lib/reply.js:132:26)\n    at send_reply (./minifiers/routes/file.js:180:9)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async module.exports (./minifiers/routes/file.js:95:3)","code":"FST_ERR_REP_ALREADY_SENT","name":"FastifyError","statusCode":500},"msg":"Reply was already sent, did you forget to \"return reply\" in \"/file?path=dashicons.css\" (GET)?"}


To test, try using "/file" with both do_minify=false and =true paths

http://localhost:4747/file?path=dashicons.css
http://localhost:4747/file?path=test.css

@mreishus mreishus merged commit 7019ab6 into trunk Jan 24, 2025
1 check passed
@mreishus mreishus deleted the fix-reply-already-sent branch January 24, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant