traPtitech / traQ

traQ - traP Internal Messenger Application Backend
MIT License
420 stars 28 forks source link

Echoのgzip middlewareを使う #2473

Closed pirosiki197 closed 2 months ago

pirosiki197 commented 2 months ago

現在使ってるライブラリ( https://github.com/nytimes/gziphandler )はメンテナンスされておらず、非推奨であるhttp.CloseNotifierを使っていたので、Echoのgzip middlewareに置き換えました。 http.CloseNotifierはEchoにサポートされていないので、'broken pipe' エラーが発生していましたが、今回の置き換えでこれが修正されます。

エラーログ スタックトレースを短くしてます ```json { "severity": "ERROR", "timestamp": "2024-06-28T00:31:24.969341563Z", "logger": "router", "caller": "extension/error_handler.go:46", "message": "write tcp 172.18.0.3:3000->172.18.0.1:36682: write: broken pipe", "requestId": "sk042qWMDcShs5aSa8qiFroT53vMWju4", "logging.googleapis.com/labels": {}, "logging.googleapis.com/sourceLocation": { "file": "/go/src/github.com/traPtitech/traQ/router/extension/error_handler.go", "line": "46", "function": "github.com/traPtitech/traQ/router.newEcho.ErrorHandler.func1" }, "serviceContext": { "service": "traq", "version": "v3.18.0.3754d71" }, "stacktrace": "github.com/traPtitech/traQ/router.newEcho.ErrorHandler.func1\n\t/go/src/github.com/traPtitech/traQ/router/extension/error_handler.go:46\ngithub.com/labstack/echo/v4.(*context).Error\n\t/go/pkg/mod/github.com/labstack/echo/v4@v4.12.0/context.go:620\ngithub.com/traPtitech/traQ/router/middlewares.Gzip.func1.1.1\n\t/go/src/github.com/traPtitech/traQ/router/middlewares/gzip.go:31\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2166\ngithub.com/NYTimes/gziphandler.GzipHandlerWithOpts.func1.1\n\t/go/pkg/mod/github.com/!n!y!times/gziphandler@v1.1.1/gzip.go:336\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2166\ngithub.com/traPtitech/traQ/router/middlewares.Gzip.func1.1\n\t/go/src/github.com/traPtitech/traQ/router/middlewares/gzip.go:33" } ```