Skip to content

POC for synchronous error rendering - #179

Merged
dcramer merged 5 commits into
mainfrom
feat/error-loading-api
Dec 1, 2023
Merged

dcramer merged 5 commits into
mainfrom
feat/error-loading-api

Conversation

@dcramer

@dcramer dcramer commented Nov 30, 2023 •

Copy link
Copy Markdown
Member

High level:

  • Expose Spotlight.trigger(eventName, eventPayload)
  • Create "sentry:showError" event (expection is integrations namespace events).
  • Trigger "sentry:showError" with eventId and event to synchronously render current errors.

@vercel

vercel Bot commented Nov 30, 2023 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
spotlightjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 1, 2023 5:02pm

});

if (process.env.NODE_ENV === 'development') {
import('@spotlightjs/astro').then(Spotlight => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

so we could actually add localStorage settings into spotlight and make this a default behavior for any unhandled error coming in too.

can also keep this behavior (i think we NEED it) and continue w/ a setting to toggle it

@@ -4,130 +4,102 @@ import Card from '../components/Card.astro';
---

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

just linter kicking in on this file

@dcramer

dcramer commented Nov 30, 2023 •

Copy link
Copy Markdown
Member Author

To ship this theres a few things, some imo required, some could be second pass:

  1. Clean up the router implementation. We probably need to be a bit smarter about where all the overlay code lives vs where the rendering layer starts. We should do all setup before rendering. This is still a bit all over the place, and may need abstracted via React Context helper.

  2. It'd be nice to have type safety on Spotlight.trigger.

  3. We need to figure out a path to make this little hack to inject the error smarter. On server-side this is actually pretty dang easy, but we'll still need to be framework aware (ughhhhh). I do THINK the default of "pop the modal on any unhandled error" is ok but I'm 100% sure thisll be annoying with SOA...

  4. Handle the async event loading case (noted in the PR), so when you arent serializing event with showError, it waits (with a timeout) for the event to become available. This should be handled by the Sentry integration and show an error detail page with a loading indicator. Think of it like we'd handle an async route.

@dcramer

dcramer commented Nov 30, 2023

Copy link
Copy Markdown
Member Author

We need to figure out a path to make this little hack to inject the error smarter. On server-side this is actually pretty dang easy, but we'll still need to be framework aware (ughhhhh). I do THINK the default of "pop the modal on any unhandled error" is ok but I'm 100% sure thisll be annoying with SOA...

I guess the tricky bit here, and what we'd probably want to do...

if spotlight: <inject spotlight javascript code on the Django 500.html page>

Comment thread packages/overlay/src/index.tsx Outdated
<App
integrations={initializedIntegrations}
fullScreen={fullScreen}
defaultEventId={defaultEventId}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we can remove this option then, right? (already marked as a removal candidate in the JSDoc)

@Lms24 Lms24 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the big problem here is that we can't reliably detect what kinds of errors should open Spotlight vs. which ones shouldn't.

Checking handled won't do the trick because JS SDKs always set handled: false unless users manually called captureException.

Comment on lines +29 to +33
const onRenderError = (e: CustomEvent) => {
log('Sentry Event', e.detail.event_id);
if (e.detail.event) sentryDataCache.pushEvent(e.detail.event);
// TODO: handle async
openSpotlight(`/errors/${e.detail.eventId}`);
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wdyt about passing openSpotlight to the setup hook callback instead of importing it from ~/index?
I think this would isolate the integrations more from the skeleton.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That could work though we likely need a larger context manager. I dont think we should abstract too much away from React

@dcramer
dcramer merged commit 8eacdb3 into main Dec 1, 2023
@dcramer
dcramer deleted the feat/error-loading-api branch December 1, 2023 17:04
BYK added a commit that referenced this pull request Mar 16, 2026
- Bump hono direct dep from ^4.12.4 to ^4.12.7 (prototype pollution fix)
- Add pnpm overrides for: flatted (>=3.4.0), yauzl@>=3 (>=3.2.1),
  devalue (>=5.6.4), rollup@>=4 (>=4.59.0), minimatch (all ranges),
  ajv (both v6 and v8 ranges)
- Update existing tar override from >=7.5.4 to >=7.5.11
- Migrate Yarn resolutions block to pnpm.overrides (pnpm ignores
  the resolutions field entirely)
- Dismiss 4 unfixable alerts: svelte (not used, optional peer dep),
  @tootallnate/once (tolerable risk, dev-only, locked to v2),
  yauzl v2 (tolerable risk, dev-only, locked by electron/extract-zip)

Fixes dependabot alerts: #156, #158, #159, #160, #161, #162, #163,
#164, #165, #167, #168, #169, #170, #171, #172, #173, #179, #180,
#181, #182, #183, #185
Dismisses: #157, #166, #178, #184

This branch was successfully deployed

1 active deployment
Preview — aeaf8165 Deployed Dec 1, 2023 by vercel[bot]
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