What does --throw really do?

I just did a k6 run --throw …
and see this:

ERROR GoError: Get "http://http://prompt-kporg-healthreminder-qa.ttgprompt.net:8284/kporg/welcome/14404339": lookup http on server misbehaving
    at github.com/loadimpact/k6/js/common.Bind.func1 (native)

The “http://http://” is my fault in my script. It means that it is attempting a DNS lookup of a host called “http”. The “server misbehaving” is a useless internal error message from the go runtime if a DNS lookup failed.

But why didn’t it abort the run instead of just logging that error, since I have --throw ?

Hi @mda,

I don’t think it is clearly stated in the documentation but throw doesn’t abort the run, it just throws ( :wink: ) an exception when an HTTP error occurs instead of setting error codes or and expecting you to handle it. This means that if you don’t have try-catch around the HTTP call it will abort the iteration.

There are some plans for having a lot of uncaught errors lead to stopping the script by default and having it be configurable, but this hasn’t happened yet.

Here is also proposal on API to abort the test, including a current workaround.

Hope this helps you and good luck