pterodactyl / panel

Pterodactyl® is a free, open-source game server management panel built with PHP, React, and Go. Designed with security in mind, Pterodactyl runs all game servers in isolated Docker containers while exposing a beautiful and intuitive UI to end users.
https://pterodactyl.io
Other
6.81k stars 1.74k forks source link

Files cannot be opened while being edited #3131

Closed kakduman closed 3 years ago

kakduman commented 3 years ago

Background (please complete the following information):

Describe the bug Opening a large file that the server is writing to (e.g. latest.log on a Minecraft server while the console is outputting a lot of information) causes an error and the file contents are displayed as an error rather than the actual file contents. For example, opening latest.log at a size of 3MB while I was pregenerating 3 worlds simultaneously (about 3 console outputs per second) displays this rather than the actual file contents: image {"errors":[{"code":"DaemonConnectionException","status":"200","detail":"[Wings Error]: There was an exception while attempting to communicate with the daemon resulting in a HTTP\/200 response code. This exception has been logged."}]}

The error is not shown as a popup. It appears that the error IS the contents of the file. The file still maintains its regular contents unless the version showing only the error is saved.

To Reproduce Steps to reproduce the behavior:

  1. Find a way to output a ton of information to the console and save that information. Here's a python script that'll spam a ton of output into a file called console.log: https://bin.birdflop.com/obazokimiq.py. Use the discord.py egg
  2. Open console.log
  3. See error.

Expected behavior Either the file contents should be displayed accurately or there should be a popup that says that the file contents could not be displayed rather than making it appear like the error message IS the content of the file. The current formatting is misleading and makes the user think that the contents of the file are something different than its actual contents.

DaneEveritt commented 3 years ago

Wings error:

ERROR: [Apr  4 17:32:41.979] error while handling HTTP request error=http: wrote more than the declared Content-Length request_id=6534c472-39e4-4e84-9d4a-766bc7986c51 server_id=2efa4996-4db3-4eeb-9b2d-6b9a70f5d79d status=500 url=/api/servers/2efa4996-4db3-4eeb-9b2d-6b9a70f5d79d/files/contents?file=%2Fconsole.log

Stacktrace:
http: wrote more than the declared Content-Length
github.com/pterodactyl/wings/router.getServerFileContents
    /home/vagrant/wings/router/router_server_files.go:51
github.com/gin-gonic/gin.(*Context).Next
    /home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161
github.com/pterodactyl/wings/router/middleware.ServerExists.func1
    /home/vagrant/wings/router/middleware/middleware.go:274
github.com/gin-gonic/gin.(*Context).Next
    /home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161
github.com/pterodactyl/wings/router/middleware.RequireAuthorization.func1
    /home/vagrant/wings/router/middleware/middleware.go:302
github.com/gin-gonic/gin.(*Context).Next
    /home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161
github.com/pterodactyl/wings/router/middleware.RequireAuthorization.func1
    /home/vagrant/wings/router/middleware/middleware.go:302
github.com/gin-gonic/gin.(*Context).Next
    /home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161
github.com/gin-gonic/gin.LoggerWithConfig.func1
    /home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/logger.go:241
github.com/gin-gonic/gin.(*Context).Next
    /home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161
github.com/pterodactyl/wings/router/middleware.AttachApiClient.func1
    /home/vagrant/wings/router/middleware/middleware.go:177
github.com/gin-gonic/gin.(*Context).Next
    /home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161
github.com/pterodactyl/wings/router/middleware.AttachServerManager.func1
    /home/vagrant/wings/router/middleware/middleware.go:168
github.com/gin-gonic/gin.(*Context).Next
    /home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161
github.com/pterodactyl/wings/router/middleware.SetAccessControlHeaders.func1
    /home/vagrant/wings/router/middleware/middleware.go:251
github.com/gin-gonic/gin.(*Context).Next
    /home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161
github.com/pterodactyl/wings/router/middleware.CaptureErrors.func1
    /home/vagrant/wings/router/middleware/middleware.go:194
github.com/gin-gonic/gin.(*Context).Next
    /home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161
github.com/pterodactyl/wings/router/middleware.AttachRequestID.func1
    /home/vagrant/wings/router/middleware/middleware.go:159
github.com/gin-gonic/gin.(*Context).Next
    /home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161
github.com/gin-gonic/gin.RecoveryWithWriter.func1
    /home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/recovery.go:83
github.com/gin-gonic/gin.(*Context).Next
    /home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161
github.com/gin-gonic/gin.(*Engine).handleHTTPRequest
    /home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/gin.go:409
github.com/gin-gonic/gin.(*Engine).ServeHTTP
    /home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/gin.go:367
net/http.serverHandler.ServeHTTP
    /usr/lib/go-1.15/src/net/http/server.go:2843
net/http.(*conn).serve
    /usr/lib/go-1.15/src/net/http/server.go:1925
runtime.goexit
    /usr/lib/go-1.15/src/runtime/asm_amd64.s:1374

2021/04/04 17:32:42 [Recovery] 2021/04/04 - 17:32:42 panic recovered:
http: wrote more than the declared Content-Length
/home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/render/json.go:59 (0x12255ed)
    JSON.Render: panic(err)
/home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:841 (0x122d65e)
    (*Context).Render: if err := r.Render(c.Writer); err != nil {
/home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:884 (0x135146f)
    (*Context).JSON: c.Render(code, render.JSON{Data: obj})
/home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:192 (0x135140a)
    (*Context).AbortWithStatusJSON: c.JSON(code, jsonObj)
/home/vagrant/wings/router/middleware/middleware.go:97 (0x1351286)
    (*RequestError).Abort: c.AbortWithStatusJSON(status, gin.H{"error": re.msg, "request_id": reqId})
/home/vagrant/wings/router/middleware/middleware.go:213 (0x1353311)
    CaptureErrors.func1: captured.Abort(c, status)
/home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 (0x1227c68)
    (*Context).Next: c.handlers[c.index](c)
/home/vagrant/wings/router/middleware/middleware.go:159 (0x1352c77)
    AttachRequestID.func1: c.Next()
/home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 (0x1227c68)
    (*Context).Next: c.handlers[c.index](c)
/home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/recovery.go:83 (0x12457e5)
    RecoveryWithWriter.func1: c.Next()
/home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 (0x1227c68)
    (*Context).Next: c.handlers[c.index](c)
/home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/gin.go:409 (0x123648d)
    (*Engine).handleHTTPRequest: c.Next()
/home/vagrant/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/gin.go:367 (0x12355c7)
    (*Engine).ServeHTTP: engine.handleHTTPRequest(c)
/usr/lib/go-1.15/src/net/http/server.go:2843 (0x9103ea)
    serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/usr/lib/go-1.15/src/net/http/server.go:1925 (0x90962c)
    (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/usr/lib/go-1.15/src/runtime/asm_amd64.s:1374 (0x4a59a0)
    goexit: BYTE    $0x90   // NOP