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

Timeouts with Docker TTY #136

Open
caarlos0 opened this issue May 10, 2023 · 1 comment
Open

Timeouts with Docker TTY #136

caarlos0 opened this issue May 10, 2023 · 1 comment

Comments

@caarlos0
Copy link
Collaborator

Not sure if it is intended or not, but if you run a docker container with --tty, many queries termenv does timeout.

Minimum reproducible:

// main.go
package main

import (
	"fmt"

	"github.com/muesli/termenv"
)

func main() {
	fmt.Println("BG", termenv.BackgroundColor())
}
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o a .
docker run --rm --tty -v $PWD:/tmp alpine /tmp/a
@johnstcn
Copy link

johnstcn commented Jun 1, 2023

I amended @caarlos0 's example above to write tracing output:

// main.go
package main

import (
	"fmt"
	"os"
	"runtime/trace"

	"github.com/muesli/termenv"
)

func main() {
	f, err := os.OpenFile("/tmp/trace.out", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)
	if err != nil {
		panic(err)
	}
	defer f.Close()
	trace.Start(f)
	defer trace.Stop()
	fmt.Println("BG", termenv.BackgroundColor())
}
// go.mod
module termenvtimeout

go 1.20

require github.com/muesli/termenv v0.15.1

require (
	github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
	github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
	github.com/mattn/go-isatty v0.0.17 // indirect
	github.com/mattn/go-runewidth v0.0.14 // indirect
	github.com/rivo/uniseg v0.2.0 // indirect
	golang.org/x/sys v0.6.0 // indirect
)

Running with Docker (in this case, Colima v0.5.5 aarch64) shows the following:

$ GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o a .
$ docker run --rm --tty -v $PWD:/tmp alpine time /tmp/a
^[]11;rgb:14a7/195f/1efb^G^[[116;1RBG #000000
real	0m 5.03s
user	0m 0.00s
sys	0m 0.00s

I'm attaching the resulting trace, but here's the syscall graph for reference:

image

It looks like the culprit is https://github.com/muesli/termenv/blob/master/termenv_unix.go#L142

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

No branches or pull requests

2 participants