Skip to content

Log messages for uncaught errors do not have source (or any other identifiable attribute) #3842

@nadiamoe

Description

@nadiamoe

Brief summary

Log lines generated by uncaught errors, such as throw new Error("foobar");, do not have any identifiable attribute that allows to programatically check if the log line comes from an uncaught throwable.

Simples reproduction would be something like:

roobre@Archiroo 󱃾 curry-admin@Curry
16:56:29 /tmp/roobre $> cat throw.js

export default async function () {
  throw new Error("foobar");
}

roobre@Archiroo 󱃾 curry-admin@Curry
16:56:41 /tmp/roobre $> k6 run throw.js --log-format logfmt --log-output=file=throw.log

          /\      |‾‾| /‾‾/   /‾‾/
     /\  /  \     |  |/  /   /  /
    /  \/    \    |     (   /   ‾‾\
   /          \   |  |\  \ |  (‾)  |
  / __________ \  |__| \__\ \_____/ .io

     execution: local
        script: throw.js
        output: -

     scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):
              * default: 1 iterations for each of 1 VUs (maxDuration: 10m0s, gracefulStop: 30s)


     data_received........: 0 B 0 B/s
     data_sent............: 0 B 0 B/s
     iteration_duration...: avg=30.22µs min=30.22µs med=30.22µs max=30.22µs p(90)=30.22µs p(95)=30.22µs
     iterations...........: 1   6937.458809/s


running (00m00.0s), 0/1 VUs, 1 complete and 0 interrupted iterations
default ✓ [======================================] 1 VUs  00m00.0s/10m0s  1/1 iters, 1 per VU

roobre@Archiroo 󱃾 curry-admin@Curry
16:56:42 /tmp/roobre $> cat throw.log
time="2024-07-12T16:56:42+02:00" level=error msg="Uncaught (in promise) Error: foobar\n\tat file:///tmp/roobre/throw.js:3:8(3)\n" executor=per-vu-iterations scenario=default

Other cases include the "browser not found in registry" error:

time="2024-07-12T16:47:49+02:00" level=error msg="Uncaught (in promise) GoError: browser not found in registry. make sure to set browser type option in scenario definition in order to use the browser module\n\tat github.com/grafana/xk6-browser/browser.syncMapBrowser.func7 (native)\n\tat file:///tmp/roobre/browser.js:20:15(4)\n" executor=shared-iterations scenario=default

k6 version

k6 v0.52.0 (commit/20f8febb5b, go1.22.4, linux/amd64)

OS

Arch linux

Docker version and image (if applicable)

No response

Steps to reproduce the problem

k6 run --log-format logfmt --log-output=file=throw.log

export default async function () {
  throw new Error("foobar");
}

Observe the matching log line does not have any attribute.

Expected behaviour

A log attribute would be nice to identify this logs programmatically and react to them. Something like source=throwable or something along those lines.

Actual behaviour

As described above.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions