Skip to content
Merged
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
Expand Up @@ -93,6 +93,35 @@ export class ExampleExceptionFilter extends BaseExceptionFilter {
</SplitSection>
</SplitLayout>

<Expandable title="Are you using WebSockets?">

<SplitLayout>
<SplitSection>
<SplitSectionText>

`SentryGlobalFilter` handles WebSocket exceptions, but NestJS doesn't apply filters registered via `APP_FILTER` to WebSocket gateways. To make sure errors thrown in a gateway are captured, add the `@UseFilters()` decorator directly to the gateway class, even if `SentryGlobalFilter` is already registered as a global provider.

</SplitSectionText>
<SplitSectionCode>

Comment on lines +102 to +106

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: The documentation for SentryGlobalFilter omits the minimum SDK version required for WebSocket exception handling, which can lead to silent error-capturing failures on older versions.
Severity: MEDIUM

Suggested Fix

Update the documentation to specify the minimum version of the @sentry/nestjs SDK required for SentryGlobalFilter to capture WebSocket exceptions. For example, add a note stating that this feature requires a specific version or newer.

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:
platform-includes/getting-started-capture-errors/javascript.nestjs.mdx#L102-L106

Potential issue: The documentation asserts that `SentryGlobalFilter` handles WebSocket
exceptions in NestJS. However, this functionality was introduced in a specific version
of the `@sentry/nestjs` SDK (e.g., v8.40.0). The guide does not mention this version
requirement. Developers using an older, unsupported SDK version who follow this
documentation will find that their WebSocket exception filters fail silently, and errors
will not be captured by Sentry. This creates a situation where error handling appears to
be correctly configured but is non-functional.

Did we get this right? 👍 / 👎 to inform future reviews.

```typescript {1, 3, 5}
import { UseFilters } from "@nestjs/common";
import { WebSocketGateway } from "@nestjs/websockets";
import { SentryGlobalFilter } from "@sentry/nestjs/setup";

@UseFilters(new SentryGlobalFilter())
@WebSocketGateway()
export class YourGateway {
// ...your event handlers
}
```

</SplitSectionCode>
</SplitSection>
</SplitLayout>

</Expandable>

<Expandable title="Are you using Microservices?">

<SplitLayout>
Expand Down
Loading