cloudflare / cloudflare/workerd
🐛 Workers Logs loses Error name/message after `workerd` errorInfo stack normalization
- Dominant language
- C++
- Stars
- 8.7k
- Forks
- 739
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 174
Description
When logging a native `Error` together with structured context:
```ts
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 cloudflare/workerd@21b8231cf826ea8f4c9be85118013a46a2cc7c8e
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:
```ts
export default {
fetch() {
const err = new TypeError("CF_ERROR_MESSAGE_SENTINEL");
console.error(err, {
extra: {
sentinel: "CF_EXTRA_SENTINEL",
},
});
return new Response("ok");
},
};
```
Then, running a request against this worker, I expect to see `TypeError: CF_ERROR_MESSAGE_SENTINEL` displayed in the Observability tab, but instead:
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 cloudflare/workerd@21b8231cf826ea8f4c9be85118013a46a2cc7c8e appears to be the commit that broke the error-logging contract.
Contributor guide
Research direction
Start with the console.* errorInfo handling associated with cloudflare/workerd@21b8231cf826ea8f4c9be85118013a46a2cc7c8e and determine where the production ingestion path uses errorInfo.stack. Run the minimal Worker reproduction and verify that the Observability event preserves the Error name and message in the top-level message and $metadata.error alongside the stack frames.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, javascript
- Domain
- backend, observability
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100