Baileys
Baileys copied to clipboard
[BUG] this.constructor.toObject is not a function
Describe the bug
When I try to JSON.stringify classes from WASignalGroup/GroupProtocol
, I get this error:
TypeError: this.constructor.toObject is not a function
at Object.toJSON
at JSON.stringify
...
Cause https://github.com/adiwajshing/Baileys/blob/master/WASignalGroup/GroupProtocol.js#L256 + more occurences in the file (possibly not a supported format by newer node versions)
Suggested solution: using class literals instead of this.constructor
To Reproduce Steps to reproduce the behavior:
- Created a new connection
- A message of the mentioned classes came and is put into store via an event listener
- Serialized store
Expected behavior JSON.stringify should not fail
Environment (please complete the following information):
- Is this on a server? YES (node version 14)
- What do your
connectOptions
look like?
{
version,// fetchLatestBaileysVersion()
logger: state.logger, // error level
markOnlineOnConnect: false,
auth: state.authState, // custom DynamoDB based implementation
syncFullHistory: true,
msgRetryCounterMap: state.msgRetryCounterMap,
connectTimeoutMs: 5 * 60 * 1000,
defaultQueryTimeoutMs: undefined,
keepAliveIntervalMs: 10000,
browser: Browsers.macOS('Desktop'),
}
- Do you have multiple clients on the same IP? NO
- Are you using a proxy? NO
Additional context I have a custom store implementation which uses JSON.stringify to make a storable representation. When classes from the mentioned file get there, it fails.
This issue is stale because it has been open 6 days with no activity. Remove the stale label or comment or this will be closed in 2 days
Still relevant
This issue is stale because it has been open 6 days with no activity. Remove the stale label or comment or this will be closed in 2 days
Still relevant
This issue is stale because it has been open 6 days with no activity. Remove the stale label or comment or this will be closed in 2 days
Still an issue
This issue is stale because it has been open 6 days with no activity. Remove the stale label or comment or this will be closed in 2 days
Still an issue
This issue is stale because it has been open 6 days with no activity. Remove the stale label or comment or this will be closed in 2 days