Skip to content

🐛 Workers Logs loses Error name/message after workerd errorInfo stack normalization #6926

Description

@allezxandre

When logging a native Error together with structured context:

console.log(error,extra);

Cloudflare Workers Logs currently stores the error as only the stripped stack frames. However, it appears the Cloudflare platform prints .stack, so on the Observability tab of the Cloudflare worker, instead of:

Error Name: error message
at worker.js (123)...

we read:

 at worker.js (123)...

And the error’s name and message are lost from both the top-level message and $metadata.error.

This appears to be a regression related to the recent console.*errorInfo work, specifically 21b8231

That commit deliberately changed errorInfo.stack to a stack containing only the frames.
That makes sense for the structured ErrorInfo representation, but the production Workers Logs ingestion path appears to use errorInfo.stack itself as the canonical log message without recombining it with errorInfo.name and errorInfo.message.


Minimal reproduction

Deploy the following code as a new Worker:

exportdefault{fetch(){consterr=newTypeError("CF_ERROR_MESSAGE_SENTINEL");console.error(err,{extra: {sentinel: "CF_EXTRA_SENTINEL",},});returnnewResponse("ok");},};

Then, running a request against this worker, I expect to see TypeError: CF_ERROR_MESSAGE_SENTINEL displayed in the Observability tab, but instead:

Image

In particular, the original Error.name and Error.message are nowhere in the ingested event.

I was not sure where I should post this issue, because it has more to do with the Cloudflare platform than workerd, so I'm filing it here because 21b8231 appears to be the commit that broke the error-logging contract.

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