Skip to content

Commit 481fc12

Browse files
committed
try catch
1 parent d503485 commit 481fc12

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/node/src/integrations/tracing/langgraph/instrumentation.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,12 @@ export class SentryLangGraphInstrumentation extends InstrumentationBase<LangGrap
107107
}
108108

109109
// Patch createReactAgent to instrument the agent creation and invocation
110-
if (exports.createReactAgent && typeof exports.createReactAgent === 'function') {
111-
const originalCreateReactAgent = exports.createReactAgent;
110+
const wrappedCreateReactAgent = instrumentCreateReactAgent(exports.createReactAgent as (...args: unknown[]) => CompiledGraph, options);
111+
try {
112+
exports.createReactAgent = wrappedCreateReactAgent;
113+
} catch (error) {
112114
Object.defineProperty(exports, 'createReactAgent', {
113-
value: instrumentCreateReactAgent(originalCreateReactAgent as (...args: unknown[]) => CompiledGraph, options),
115+
value: wrappedCreateReactAgent,
114116
writable: true,
115117
enumerable: true,
116118
configurable: true,

0 commit comments

Comments
 (0)