Skip to content

Conversation

@zhiyan114
Copy link
Owner

Add sentry to eval to debug scope leak issue. The codebase is so bad that even AsyncContext cant contain it 😭

@zhiyan114 zhiyan114 merged commit 1abbd76 into master Jan 4, 2026
4 checks passed
@zhiyan114 zhiyan114 deleted the dev branch January 4, 2026 19:48
SlashCommandBuilder
} from "discord.js";
import { baseCommand } from "../../core/baseCommand";
import Sentry from "@sentry/node-core";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The default import import Sentry from "@sentry/node-core"; is incorrect as the package has no default export. This results in Sentry being undefined, causing errors in the eval command.
Severity: HIGH | Confidence: High

🔍 Detailed Analysis

The code uses a default import import Sentry from "@sentry/node-core";. However, the @sentry/node-core package does not provide a default export, which results in the Sentry variable being undefined. This undefined value is then passed into the eval function. When any evaluated code attempts to call a function on the sentry parameter, such as sentry.captureException(), it will throw a TypeError because it is trying to access a property on undefined. This breaks the intended functionality of exposing Sentry to the eval command.

💡 Suggested Fix

Change the import to a namespace import: import * as Sentry from "@sentry/node-core";. This will correctly import all named exports into the Sentry object, making them available within the eval command as intended.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/commands/discord/Eval.ts#L14

Potential issue: The code uses a default import `import Sentry from
"@sentry/node-core";`. However, the `@sentry/node-core` package does not provide a
default export, which results in the `Sentry` variable being `undefined`. This
`undefined` value is then passed into the `eval` function. When any evaluated code
attempts to call a function on the `sentry` parameter, such as
`sentry.captureException()`, it will throw a `TypeError` because it is trying to access
a property on `undefined`. This breaks the intended functionality of exposing Sentry to
the `eval` command.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 8141812

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants