-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(gatsby): fix broken GraphQL resolver tracing #29015
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -566,13 +566,17 @@ export function wrappingResolver<TSource, TArgs>( | |
) | ||
activity.start() | ||
} | ||
try { | ||
return resolver(parent, args, context, info) | ||
} finally { | ||
const result = resolver(parent, args, context, info) | ||
|
||
const endActivity = (): void => { | ||
if (activity) { | ||
activity.end() | ||
} | ||
} | ||
if (typeof result?.then === `function` && activity) { | ||
result.then(endActivity, endActivity) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While this won't swallow the error, I think it will suppress nodejs' builtin reporting for uncaught promises (right? because it sees the error is handled at least somewhere) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it's a different promise chain than the one returned. So it is not affecting unhandled rejections. Also double-checked with this example in node: const foo = new Promise(function (resolve, reject) {
setTimeout(() => {
reject(new Error("Err"));
}, 1000);
});
const func = () => {};
foo.then(func, func);
foo.then(() => { console.log(`test`); }); |
||
} | ||
vladar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return result | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be dropped since we test and shortcut return above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typescript disagrees.
This file has incomplete typings but if I add proper typings to
activity
and remove this check I get TS error:TS2339: Property 'end' does not exist on type 'void | IActivity'. Property 'end' does not exist on type 'void'.