Page MenuHomePhabricator

console.logging proxy metrics object fails because it doesn't recognise "util.inspect.custom" as a valid property
Open, Needs TriagePublicBUG REPORT

Description

List of steps to reproduce

  • Console.log any service-runner metrics object / console.log(app.metrics);

What happens?:

Get this error

{"name":"citoid","hostname":"dull","pid":4006,"level":50,"levelPath":"error/metrics","msg":"No such method 'Symbol(nodejs.util.inspect.custom)' in Metrics","time":"2022-01-27T13:50:55.339Z","v":0}

What should have happened instead?:
It should print the metrics object.
The problem is here in the Proxy handler which we use to intercept any non properties;
https://github.com/wikimedia/service-runner/blob/19c4087e9229f6bd948353c698297bfcb2bc34de/lib/metrics/index.js#L130

If we don't throw the error the object prints. I'm not quite sure why because target[prop] SHOULD transverse the full property tree - only hasOwnProperty() *doesn't* according to the js docs- but for some reason it doesn't? Something to do with how a Proxy works maybe? But according to the docs it should work! :P