Skip to content

Commit 8ff769f

Browse files
fix(server): avoid duplicate attachment persistence spans
Delegate provider attachment persistence without opening a second span. The shared ChatAttachments operation retains its existing span and receives the same captured services. Written with Amp in an Orb. Co-authored-by: 5omeOtherGuy <[email protected]> Amp-Thread-ID: https://ampcode.com/threads/T-01a1a0b3-0b97-77d4-9fbf-85ca74a651ca
1 parent ba82410 commit 8ff769f

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎apps/server/src/provider/ProviderHostLive.ts‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ export const layer = Layer.effect(
4242
shouldRunBackgroundWork: backgroundPolicy.shouldRunScopeWork,
4343
resolveAttachmentPath: (attachment) =>
4444
resolveAttachmentPath({ attachmentsDir: config.attachmentsDir, attachment }),
45-
persistChatAttachments: Effect.fn("ProviderHost.persistChatAttachments")((input) =>
46-
persistChatAttachments(input).pipe(
47-
Effect.provideService(ServerConfig.ServerConfig, config),
48-
Effect.provideService(FileSystem.FileSystem, fileSystem),
49-
Effect.provideService(Path.Path, path),
50-
),
45+
// ChatAttachments owns the persistence span.
46+
persistChatAttachments: Effect.fnUntraced(
47+
function* (input) {
48+
return yield* persistChatAttachments(input);
49+
},
50+
Effect.provideService(ServerConfig.ServerConfig, config),
51+
Effect.provideService(FileSystem.FileSystem, fileSystem),
52+
Effect.provideService(Path.Path, path),
5153
),
5254
// DocumentText owns the path-resolution span.
5355
resolveExtractedTextPath: Effect.fnUntraced(

0 commit comments

Comments
 (0)