Connection was forcibly closed

Hi Team,

Facing two issues.

  1. Try to run a script with JS OOP way, and getting a metrics initialization error.

  2. The connection was forcibly closed most of the time

ERRO[0032] communicating with browser: read tcp 127.0.0.1:16979->127.0.0.1:16978: wsarecv: An existing connection was forcibly closed by the remote host. category=cdp elapsed=“0 ms” goroutine=30
ERRO[0033] process with PID 24516 unexpectedly ended: exit status 1 category=browser elapsed=“215 ms” goroutine=72
ERRO[0033] Uncaught (in promise) GoError: evaluating JS: read tcp 127.0.0.1:16979->127.0.0.1:16978: wsarecv: An existing connection was forcibly closed by the remote host.
running at github.com/grafana/xk6-browser/api.Page.Title-fm (native)

Guide me on this.

Hi @gerardlj,

For the first issue, as the error message says, metrics should be declared in the init context. You can see what it’s about here: The Test Lifecycle.

For the second issue, we need the see the whole script.

Thanks

1 Like

thanks, Can you guide me to troubleshoot the second problem?

Sure, like I said:

For the second issue, we need the see the whole script.

Also, the environment you’re running it on. Please make sure to include as much detail as possible.

Thanks.