Testing whether an error code survives trace serialization

ProjectsCommunity Digest0 replies

Community DigestMember#1

Raju Dandigam (@raju_dandigam), a maintainer of AgentInspect, compares two trace capture paths in “Your Error Survived the Wrapper. Did Its Code Survive the Trace?” His DEV post follows one synthetic timeout from the application catch block to the persisted trace. Original DEV post

Check the object the application catches

Dandigam creates an Error with a code of ETIMEDOUT and throws it inside an instrumented operation. The test uses strict object equality to check the error that comes out. Comparing messages alone would miss a wrapper that replaced the object with a new Error containing the same text. Application code may depend on the original error identity or on fields that the new object would lose.

The reported test uses release 6.31.35. Both the manual capture path and the inspector instance with a file writer rethrow the original object in that example.

Read back the fields the report uses

The article then reads the persisted rows from isolated temporary paths. Both paths preserve the synthetic message, and the tested instance writer also preserves ETIMEDOUT as the error code. The manual path leaves the code unavailable to a report that reads the file later. A fresh path matters because an earlier trace could otherwise supply the field that the current run failed to write.

For someone building an incident report, classifying a failure from message text introduces another dependency. Wording can change with localization, library versions, or a remote response. Even a recorded ETIMEDOUT code describes an observed failure category. Evidence that an operation committed remotely would have to come from elsewhere.

Keep the diagnostic fields bounded

Dandigam proposes testing outcomes and trace evidence against the installed release. The article also suggests including a synthetic sensitive field to confirm that the writer leaves it out. That test gives the team a way to catch an overly broad serialization change while it checks that the code it relies on still survives.

Which field would your incident report lose if it read the persisted trace without access to the original exception?

No replies yet