@sentry/cloudflare: Flue agents need a hand-written Durable Object wrapper
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 35/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- typescript
研究方向
Start with autoInstrument.ts, options.ts, and instrument.ts, then inspect the generated Flue worker shape and the cloudflare-mastra e2e app. Trace how createFlueAgentClass exposes each agent and verify the existing wrapping guard before choosing the applicable Agent or Durable Object wrapper. Done means Flue agents are instrumented without clobbering extensions, double-wrapping documented setups, or silently accepting an unmatched generated module.
由索引模型根據 Issue 內容生成。
描述
Flue runs each agent in its own Durable Object, and nothing in the SDK runs Sentry.init() in that isolate. Users have to hand-write a wrapper module and re-export it from every agent module:
// src/sentry.ts
export const cloudflare = extend({
wrap: Final =>
Sentry.instrumentDurableObjectWithSentry((env: Env) => ({ dsn: env.SENTRY_DSN }), Final),
});
// src/agents/support.ts
export { cloudflare } from '../sentry.ts';
Miss the re-export in one agent module and that agent captures nothing, with no error anywhere. The Flue Cloudflare guide (getsentry/sentry-docs#19528) covers it with a warning and a troubleshooting entry, which is a weak fix for a silent failure.
Why auto-instrumentation doesn't cover it
sentryCloudflareAutoInstrumentPlugin is gated on wrangler's main, which resolveWranglerConfig reads from disk. Flue sets main to virtual:flue/worker and adds the DO bindings in memory, inside @cloudflare/vite-plugin's config hook, and never writes either to the file. Running wrangler's own reader against a real flue init app:
unstable_readConfig('<flue app>/wrangler.jsonc')
main : undefined
durable_objects.bindings : []
So entryFilePath is never assigned and transform returns on its first line (autoInstrument.ts:65). instrument.server.ts sits behind the same gate at autoInstrument.ts:51, so it is never probed either.
Contrast the cloudflare-mastra e2e app, whose wrangler.toml has main = "src/index.ts": a real file the user wrote that exports the classes. That is why Mastra works here and Flue does not.
Where to investigate
Flue's generated worker is a real module in the graph, and it exports each agent class from a fixed shape:
export const FlueHelloAgent = createFlueAgentClass({
AgentBase: Agent,
className: "FlueHelloAgent",
extension: Reflect.get(__flue_agent_module_0__, 'cloudflare'),
});
Wrapping the result there looks viable. Open questions:
- Where options come from.
getFinalOptionsalready readsenv.SENTRY_DSN(options.ts:68), so the env fallback may be enough and the setup could end up zero-config. Aninstrument.server.*probe would need a directory to start from, since there is no realmainto sit next to. - Not double-wrapping. Anyone on the documented setup applies the wrapper inside
createFlueAgentClass, which the build cannot see._INTERNAL_wrapUnlessInstrumented(instrument.ts:96) was built for this case; confirm it covers it before relying on it. - Which wrapper. Flue builds the class with
AgentBase: Agentfromagents, so it is a real Agent rather than a plain Durable Object.instrumentAgentWithSentrymay apply and carry more thaninstrumentDurableObjectWithSentry. - Failing loudly. The generated module is marked "Do not edit" and is not API. A transform that matches it should warn when it finds no
createFlueAgentClasscall, rather than silently shipping an uninstrumented worker.
One thing to rule out up front: do not reuse the extension slot. resolveCloudflareExtension reads exactly one cloudflare export per agent, with no array and no registry, so taking it would clobber a user's own extension.
- 主要語言
- TypeScript
- 星號
- 8.7k
- 分支
- 1.9k
- 平均合併
- 1 天 16 小時
- 30 天內合併 PR
- 576
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
getsentry/sentry-javascript 的其他 Issue
-
Browser Bug Next.js Traces Waiting for: Product Owner
難度 2/5 1-3 小時 新手友好度 75/100
getsentry/sentry-javascript#24672 · 1 則留言 ·
-
Flaky Test React Router Framework Spans Tests
難度 2/5 1-3 小時 新手友好度 68/100
getsentry/sentry-javascript#24348 · 1 則留言 ·
-
javascript
難度 2/5 1-3 小時 新手友好度 75/100
getsentry/sentry-javascript#24200 · 2 則留言 ·
-
javascript Task
難度 2/5 1-3 小時 新手友好度 82/100
getsentry/sentry-javascript#24134 · 1 則留言 ·
-
Cloudflare Workers javascript Tests
難度 2/5 1-3 小時 新手友好度 78/100
getsentry/sentry-javascript#24051 · 1 則留言 ·
查看 getsentry/sentry-javascript 的全部 Issue
相似的 Issue
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs 未關閉
難度 2/5 1-3 小時 新手友好度 70/100
-
Crush 未關閉
難度 1/5 1 小時以內 新手友好度 85/100
catppuccin/catppuccin#3125 ·
-
難度 1/5 1 小時以內 新手友好度 90/100
ElementsProject/cln-application#167 · 1 則留言 · 1 個 reaction ·
-
難度 2/5 1-3 小時 新手友好度 75/100
Quantco/pnpm-licenses#17 ·
-
難度 2/5 1-3 小時 新手友好度 75/100