Skip to content

Conversation

jennifer-shehane
Copy link
Member

@jennifer-shehane jennifer-shehane commented Oct 7, 2025

  • Closes

Additional details

We're getting some errors in Sentry that are reporting [object Object] and I'd like to be able to actually see the errors. Example error.

This solution isn't foolproof - it's expecting a string or object, but I just want a quick solution. I went down a rabbithole of consolidating all the error serialization one day and it was too much.

Steps to test

How has the user experience changed?

N/A

PR Tasks


Note

Safely serialize non-Error exceptions using serialize-error and propagate this in Studio error handling/reporting, with new tests and dependency.

  • Error handling:
    • Add exception.safeErrorSerialize in packages/server/lib/cloud/exception.ts using serialize-error to robustly stringify unknown errors (handles circular refs, primitives, undefined/null).
    • Use safe serialization when converting non-Error values to Error in:
      • packages/server/lib/cloud/api/studio/report_studio_error.ts
      • packages/server/lib/cloud/studio/studio.ts (sync and async invocations)
  • Tests:
    • Add comprehensive unit tests for safeErrorSerialize in packages/server/test/unit/cloud/exceptions_spec.js.
    • Extend Studio tests to verify non-Error handling in both sync/async paths and API reporting.
  • Dependencies:
    • Add serialize-error to packages/server/package.json.

Written by Cursor Bugbot for commit 0be6bef. This will update automatically on new commits. Configure here.

cursor[bot]

This comment was marked as outdated.

Copy link

cypress bot commented Oct 7, 2025

cypress    Run #66319

Run Properties:  status check failed Failed #66319  •  git commit 0be6bef234: fix undefined
Project cypress
Branch Review stringify-studio-errors
Run status status check failed Failed #66319
Run duration 16m 29s
Commit git commit 0be6bef234: fix undefined
Committer Jennifer Shehane
View all properties for this run ↗︎

Test results
Tests that failed  Failures 1
Tests that were flaky  Flaky 1
Tests that did not run due to a developer annotating a test with .skip  Pending 11
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 631
View all changes introduced in this branch ↗︎
UI Coverage  0%
  Untested elements 4  
  Tested elements 0  
Accessibility  100%
  Failed rules  0 critical   0 serious   0 moderate   0 minor
  Failed elements 0  

Tests for review

Failed  cypress/e2e/studio/studio.cy.ts • 1 failed test • app-e2e

View Output

Test Artifacts
Cypress Studio > updates an existing test with assertions Test Replay Screenshots
Flakiness  cypress/e2e/cypress-origin-communicator.cy.ts • 1 flaky test • app-e2e

View Output

Test Artifacts
Cypress In Cypress Origin Communicator > primary origin memory leak prevention > cleans up the primaryOriginCommunicator events when navigating away from the /specs to /runs Test Replay Screenshots

cursor[bot]

This comment was marked as outdated.

* Safely serializes an error object to a string, handling circular references
* and other non-serializable values that would cause JSON.stringify to throw.
*/
export function safeErrorSerialize (error: unknown): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should just use the structured clone algorithm.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yah this is why I didn't want to get deep into this 😅

Before I looked at using https://www.npmjs.com/package/serialize-error

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be addressed now

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants