Skip to content

uncaught error when running locally #15

@tseelbach

Description

@tseelbach

When testing assert failures locally in vsCode, the monitoring scripts as written per the examples will fail with something like:

Uncaught Object Proxy(Error)
at throwUnhandledRejectionsMode (<node_internals>/internal/process/promises:391:5)
at processPromiseRejections (<node_internals>/internal/process/promises:470:17)
at processTicksAndRejections (<node_internals>/internal/process/task_queues:96:32)
promises:391
Process exited with code 1

This is because the assert failure causes an unhandled exception locally.
In Instana sythetic monitoring there is a handler for this so we get the expected result from the assert like this example:

AssertionError [ERR_ASSERTION]: Expected a 200 status code, statusCode is 200
at ReadOnlyHandler.apply (vm/bridge.js:468:15)
at /tmp/96VHwN2S5idFET8uFR54_bb32189c-1985-4271-a3f6-0ac560879410/script.js:38:10
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

To fix this locally I added this to the bottom of my async function:

})() //.catch(error => {
//console.error('Local execution error:', error.message);
//});
// Failed asserts will throw an exception.
// For local execution, uncomment the above 3 lines to catch and print the error.
// In Instana Synthetic Monitoring, errors are handled by the platform

There is an example of this in examples/got-get.js but it's not documented.
It would be helpful if you added this code to some of the examples, and a paragraph in the README.
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions