getsentry / getsentry/sentry-javascript

Cloudflare capture crashes / data before we export the default fetch handler

未关闭
#24,375 1 条评论 0 个 reaction 已指派 1 人 已被 @JPeer264 认领 在 GitHub 查看
Cloudflare Workers Feature
主要语言
TypeScript
星标
8.7k
派生
1.8k
平均合并
1 天 17 小时
30 天内合并 PR
523

描述

### Problem Statement

Potentially the following Error would never be seen within Sentry:

```js
// file:src/index.ts

import diagnostics_channel from 'diagnostics_channel';

const channel = diagnostics_channel.channel('my-channel');
const app = new Hono();

// never been seen by Sentry
throw new Error();

// never been seen by Sentry
channel.publish({
some: 'data',
});

export default {
fetch: app.fetch,
scheduled: async (batch, env) => {},
}
```

### Solution Brainstorm

Since we introduced cachedClients #23151 we could potentially inject an `Sentry.init` at the top of the workers entrypoint with Vite:

```js
// file:src/index.ts

// following is being injected automatically and uses `Sentry.init`
import ./instrument.js`;

// ... the rest from above ...
```

Theoretically, `instrument.js` only sets up the client so we receive some data, and later the `withSentry` wrapped code would wrap everything as usual and reuses the previously created client.

### Additional Context

This would only work with the v11's default `cacheClient: true` and the entrypoint would not be added when `cacheClient: false`

### Priority

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。