-
I love RQ, but I'm having a particularly difficult time trying to get it to work together with a transaction ID header we use to facilitate Distributed Tracing. I have a zustand store called const useErrorStore = create(set => ({
currentError: null,
setError: err => {
logger.warn('Received a new error on the stack:', err.error);
set({ currentError: err });
// This is our service which tracks to Sentry
Tracing.traceException(err.error, { transactionID: err.transactionID });
},
})); Trying to retrieve this transaction ID (a UUIDv4) was already but I managed to create a import { useDataQuery } from './codegen.gql.ts';
export default function useData() {
const { graphQLClient, withDefaultHeaders } = useGraphQLClient();
const { setError } = useErrorStore();
// This is generated by graphql-codegen
useDataQuery(
graphQLClient,
undefined,
{
onError: error => {
// This doesn't exist but would be greatly appreciated 🙏
const transactionID = error.request.headers['x-transaction-id'];
setError({ error, retryAction: refetch, transactionID });
},
},
withDefaultHeaders(),
); Anybody here faced a similar scenario? Found a solution? Does this seem like a good suggestion? Other approaches? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
we have an |
Beta Was this translation helpful? Give feedback.
-
For anyone else stumbling across this: I've got a PR open to return request headers in |
Beta Was this translation helpful? Give feedback.
we have an
onError
callback, which gets passed theerror
, which might or might not contain the request headers, that depends on your transport layer. I don't see why the code you posted shouldn't work ?