Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(nestjs): Add support for Symbol as event name #17785

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

Open
stefanvanderwolf wants to merge 1 commit into getsentry:develop
base: develop
Choose a base branch
Loading
from stefanvanderwolf:fix/event-name-symbol

Conversation

Copy link

@stefanvanderwolf stefanvanderwolf commented Sep 25, 2025
edited
Loading

The @OnEvent decorator accepts the following types for its argument:

string | symbol | Array<string | symbol>

If a Symbol is included in an array, the code to get the eventName will throw a TypeError (String(event)) This occurs because JavaScript’s
Array.prototype.join internally calls ToString on each array element. Per the specification, ToString(Symbol) is not allowed and results in a TypeError.

To avoid this issue, do not rely on String(array) or .join() on arrays containing symbols directly. Instead, explicitly convert each element to a string while handling symbols safely.

I couldn't find a way to test adding multiple @OnEvent so the second part can be tested. It didn't have any tests before (as far as I can tell), but would be nice to add them.

doc: https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.join
doc: https://tc39.es/ecma262/multipage/abstract-operations.html#sec-tostring

seer-by-sentry[bot] reacted with hooray emoji
The @onevent decorator accepts the following types for its argument:
```typescript
string | symbol | Array<string | symbol>
``
If a Symbol is included in an array, the code to get the eventName will
throw a TypeError (String(event)) This occurs because JavaScript’s
Array.prototype.join internally calls ToString on each array element.
Per the specification, ToString(Symbol) is not allowed and results in a
TypeError.
To avoid this issue, do not rely on String(array) or .join() on arrays
containing symbols directly. Instead, explicitly convert each element to
a string while handling symbols safely.
doc: https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.join
doc: https://tc39.es/ecma262/multipage/abstract-operations.html#sec-tostring 
} else if (Array.isArray(event)) {
return event.map(eventNameFromEvent).join(',');
} else return String(event);
}
Copy link

@cursor cursor bot Sep 25, 2025

Choose a reason for hiding this comment

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

Bug: Symbol Handling Fails in Event Name Extraction

The eventNameFromEvent function at line 82 uses String(event) in its fallback, which throws a TypeError when the event is a Symbol. This prevents proper Symbol handling, contrary to the PR's intent.

Fix in Cursor Fix in Web

Copy link
Author

@stefanvanderwolf stefanvanderwolf Sep 25, 2025
edited
Loading

Choose a reason for hiding this comment

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

@chargome chargome self-assigned this Oct 3, 2025
Copy link
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

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

Makes sense to me, thanks for contributing this!

stefanvanderwolf reacted with thumbs up emoji
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@cursor cursor[bot] cursor[bot] left review comments

@chargome chargome chargome approved these changes

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /