empiricaly / empirica

Open source project to tackle the problem of long development cycles required to produce software to conduct multi-participant and real-time human experiments online.
https://empirica.ly/
Apache License 2.0
44 stars 8 forks source link

`panic: strings: negative Repeat count` on HMR #440

Closed JamesPHoughton closed 9 months ago

JamesPHoughton commented 10 months ago

Is there an existing issue for this?

What happened?

When make a change to the code in dev, the server crashes instead of successfully propagating changes to the page:

panic: strings: negative Repeat count

goroutine 52 [running]:
strings.Repeat({0x102fea100?, 0x14000f9a2a0?}, 0xe?)
        /usr/local/go/src/strings/strings.go:538 +0x394
github.com/empiricaly/empirica/internal/term.(*UI).printRefresh(0x14000ab1ea8?, {0x102ec39ba, 0x6})
        /build/internal/term/term.go:89 +0x468
github.com/empiricaly/empirica/internal/term.(*UI).process(0x14000321f80, {0x60?, {0x0?, 0x0?}, 0x14000033640?})
        /build/internal/term/term.go:230 +0x434
github.com/empiricaly/empirica/internal/term.(*UI).run(0x14000321f80)
        /build/internal/term/term.go:206 +0x3c
created by github.com/empiricaly/empirica/internal/term.(*UI).Start
        /build/internal/term/term.go:35 +0x60

Looks like there needs to be a check on this line to make sure that the passed parameter is positive: https://github.com/empiricaly/empirica/blob/1d91ea7b31b3164083f62c45fff39fda84bf06f5/internal/term/term.go#L89C3-L89C3

Steps To Reproduce

No response

Empirica Version

Version: v1.8.5
SHA:     1d91ea7
Branch:  main
Time:    2023-11-16T03:03:22Z

Client:  1.8.5
Server:  1.8.5

What OS are you seeing the problem on?

macOS

What browser are you seeing the problem on?

Chrome

Relevant log output

No response

Anything else?

I'm having trouble recreating the bug in a clean environment, partly because i don't know what log attempt is trying to display. @npaton, sent this to you in slack, but just moving it here to make tracking easier. I'll take a crack at a patch.

Code of Conduct

JamesPHoughton commented 10 months ago

This occured because I am piping logs to a file. You can replicate the error by starting the template experiment with the following command, and then making a display change.

> empirica 2>&1 | tee ./.empirica/empirica.log

The file doesn't have a column width, so the value mentioned above was going negative.

Taking out the extra log piping solves the problem, so this is low priority.