Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const Sentry = require('@sentry/node');
const { loggingTransport } = require('@sentry-internal/node-integration-tests');

Sentry.init({
dsn: 'https://[email protected]/1337',
includeLocalVariables: true,
transport: loggingTransport,
});

process.on('uncaughtException', () => {
// do nothing - this will prevent the Error below from closing this process
});

// Testing GraphQL resolver: https://github.com/getsentry/sentry-javascript/issues/16701
const resolvers = {
Query: {
testSentry: args => {
try {
args.foo.map(x => x);
return true;
} catch (error) {
Sentry.captureException(error);
return false;
}
},
},
};

function regularFunction() {
resolvers.Query.testSentry({ foo: undefined });
}

setTimeout(() => {
regularFunction();
}, 1000);
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,30 @@ describe('LocalVariables integration', () => {
.start()
.completed();
});

test('Should handle different function name formats', async () => {
await createRunner(__dirname, 'local-variables-name-matching.js')
.expect({
event: {
exception: {
values: [
{
stacktrace: {
frames: expect.arrayContaining([
expect.objectContaining({
function: expect.stringMatching(/^(Object\.testSentry|testSentry)$/),
vars: expect.objectContaining({
args: expect.any(Object),
}),
}),
]),
},
},
],
},
},
})
.start()
.completed();
});
});
2 changes: 1 addition & 1 deletion packages/node/src/integrations/local-variables/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function isAnonymous(name: string | undefined): boolean {

/** Do the function names appear to match? */
export function functionNamesMatch(a: string | undefined, b: string | undefined): boolean {
return a === b || (isAnonymous(a) && isAnonymous(b));
return a === b || `Object.${a}` === b || a === `Object.${b}` || (isAnonymous(a) && isAnonymous(b));
}

export interface FrameVariables {
Expand Down
Loading