Skip to content

Conversation

@jlucaso1
Copy link
Collaborator

@jlucaso1 jlucaso1 commented Oct 8, 2025

This PR is a continuation of #1891 ,but is more agressive too, so we need more tests to this changes

  1. Implemented a defer-like withAck Wrapper:

    • Introduced a new withAck higher-order function in src/Socket/messages-recv.ts.
    • This function wraps message processing logic in a try...finally block, guaranteeing that an acknowledgment (ack) is always sent to the server, even if the handler returns early or throws an error.
    • Refactored handleReceipt, handleNotification, and handleMessage to use this new pattern, eliminating scattered ack calls and preventing bugs where an ack might be missed.
  2. Hardened Core Functions Against Null/Undefined Values:

    • Message Sending (messages-send.ts): Added a guard clause to relayMessage to check for authState.creds.me.id before proceeding, preventing crashes if a message is sent before authentication is complete.
    • Message Decoding (decode-wa-message.ts): Replaced risky non-null assertions (!) on incoming message stanza attributes (id, from) with proper validation. The function now throws a descriptive Boom error if essential attributes are missing.
    • Chat ID Resolution (process-message.ts): Refactored getChatId to safely handle potentially null or undefined remoteJid and participant values by using nullish coalescing (??), preventing crashes on malformed message keys.

@whiskeysockets-bot
Copy link
Contributor

whiskeysockets-bot commented Oct 8, 2025

Thanks for opening this pull request and contributing to the project!

The next step is for the maintainers to review your changes. If everything looks good, it will be approved and merged into the main branch.

In the meantime, anyone in the community is encouraged to test this pull request and provide feedback.

✅ How to confirm it works

If you’ve tested this PR, please comment below with:

Tested and working ✅

This helps us speed up the review and merge process.

📦 To test this PR locally:

# NPM
npm install @whiskeysockets/baileys@WhiskeySockets/Baileys#chore-improve-some-type-safety

# Yarn (v2+)
yarn add @whiskeysockets/baileys@WhiskeySockets/Baileys#chore-improve-some-type-safety

# PNPM
pnpm add @whiskeysockets/baileys@WhiskeySockets/Baileys#chore-improve-some-type-safety

If you encounter any issues or have feedback, feel free to comment as well.

@jlucaso1 jlucaso1 marked this pull request as draft October 8, 2025 16:13
Copy link
Member

@purpshell purpshell left a comment

Choose a reason for hiding this comment

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

Code looks clean and makes sense, thanks.

Will need to test intensively before deployment.

@Salientekill
Copy link

Looking forward to testing

@jlucaso1 jlucaso1 marked this pull request as ready for review October 8, 2025 17:46
@jlucaso1 jlucaso1 force-pushed the chore-improve-some-type-safety branch 2 times, most recently from 7f1b30e to 7ff46ef Compare October 12, 2025 00:32
@Salientekill
Copy link

I've been testing this PR since it was released, it improved the issue of Messages waiting in groups in addition to stability improvements, I think it would be cool to merge it, it improves an annoying error that happens

@Salientekill
Copy link

Tested and working ✅

@jeffersonfelixdev
Copy link
Contributor

Tested and working ✅

@jlucaso1 jlucaso1 force-pushed the chore-improve-some-type-safety branch from 1fbeb55 to 3aa9a92 Compare October 15, 2025 17:22
@Salientekill
Copy link

It was just a merge notification to make my night 😂

@jlucaso1 jlucaso1 force-pushed the chore-improve-some-type-safety branch from 2d3f0bf to 4e41480 Compare October 19, 2025 21:45
@jlucaso1 jlucaso1 force-pushed the chore-improve-some-type-safety branch from e7f531d to 8267146 Compare October 19, 2025 22:16
@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2025

This PR is stale because it has been open for 14 days with no activity. Remove the stale label or comment or this will be closed in 14 days

@github-actions github-actions bot added the Stale label Nov 3, 2025
Salientekill pushed a commit to Salientekill/Baileys that referenced this pull request Nov 3, 2025
…hecking

- Add safe null/undefined checks throughout codebase
- Improve error handling in message processing
- Add defensive programming for edge cases
- Improve type safety in message decoding

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@purpshell
Copy link
Member

Resolve conflicts and should merge

Salientekill pushed a commit to Salientekill/Baileys that referenced this pull request Nov 19, 2025
…ets#1969 to latest Baileys

Applied PRs:
- WhiskeySockets#2067: libsignal wasm
- WhiskeySockets#2057: emit setting events
- WhiskeySockets#1969: improve retry logic

Note: PRs WhiskeySockets#1991, WhiskeySockets#1981, WhiskeySockets#1906, WhiskeySockets#1892 have conflicts with latest Baileys version and were skipped.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@github-actions github-actions bot removed the Stale label Nov 20, 2025
Salientekill pushed a commit to Salientekill/Baileys that referenced this pull request Nov 24, 2025
Salientekill pushed a commit to Salientekill/Baileys that referenced this pull request Nov 24, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2025

This PR is stale because it has been open for 14 days with no activity. Remove the stale label or comment or this will be closed in 14 days

@github-actions github-actions bot added the Stale label Dec 7, 2025
Copy link
Collaborator

@vinikjkkj vinikjkkj left a comment

Choose a reason for hiding this comment

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

Tested and working ✅

@purpshell
Copy link
Member

resolve conflicts!

@github-actions github-actions bot removed the Stale label Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants