Skip to content

Commit 48db6ac

Browse files
authored
fix(gatsby): fix broken GraphQL resolver tracing (#29015)
* fix(gatsby): fix broken GraphQL resolvers tracing * end activity for sync resolvers
1 parent 90b6e3d commit 48db6ac

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

packages/gatsby/src/schema/resolvers.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,13 +566,23 @@ export function wrappingResolver<TSource, TArgs>(
566566
)
567567
activity.start()
568568
}
569-
try {
570-
return resolver(parent, args, context, info)
571-
} finally {
569+
const result = resolver(parent, args, context, info)
570+
571+
if (!activity) {
572+
return result
573+
}
574+
575+
const endActivity = (): void => {
572576
if (activity) {
573577
activity.end()
574578
}
575579
}
580+
if (typeof result?.then === `function`) {
581+
result.then(endActivity, endActivity)
582+
} else {
583+
endActivity()
584+
}
585+
return result
576586
}
577587
}
578588

0 commit comments

Comments
 (0)