-
-
Notifications
You must be signed in to change notification settings - Fork 47
Description
What's the bug?
Using MessageComponents.prototype.row()
pushes this
onto this
, thus creating a circular reference, as shown in here on line 29:
harmony/src/structures/messageComponents.ts
Lines 23 to 32 in 08a4606
export class MessageComponents extends Array<MessageComponentData> { | |
row(cb: (builder: MessageComponents) => unknown): this { | |
const components = new MessageComponents() | |
cb(components) | |
this.push({ | |
type: MessageComponentType.ACTION_ROW, | |
components: this as MessageComponentData[] | |
}) | |
return this | |
} |
How do we reproduce it?
Call row(cb)
method on new MessageComponents()
, then try to use the component.
What should have happened?
row(cb)
should call cb()
with a new MessageComponents
, then push it to the newly created row.
What is actually happening?
It throws an error such as:
error: Uncaught (in promise) RangeError: Maximum call stack size exceeded
return d.map((data: unknown) => {
with a console output on MessageComponents
:
<ref *1> MessageComponents(1) [
{ type: 1, components: [Circular *1] }
]
What versions you're using?
- OS: macOS 14.4.1
- Deno: Deno 1.43.1
- Harmony: Harmony 2.9.0
Do you have anything to tell us more about the bug?
Undoes change done in #287, probably a simple slip.
Previous commit on the file:
harmony/src/structures/messageComponents.ts
Lines 22 to 30 in b2e0858
export class MessageComponents extends Array<MessageComponentData> { | |
row(cb: (builder: MessageComponents) => unknown): this { | |
const components = new MessageComponents() | |
cb(components) | |
this.push({ | |
type: MessageComponentType.ActionRow, | |
components | |
}) | |
return this |