Skip to content

chore(WebSocketShard): improve zlib-sync errors #10808

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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LJNeon
Copy link

@LJNeon LJNeon commented Mar 18, 2025

Please describe the changes this PR makes and why it should be merged:
The current error thrown from zlib-sync isn't great, and doesn't match what errors from node:zlib look like. This brings them more in line with node:zlib errors.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

@LJNeon LJNeon requested a review from a team as a code owner March 18, 2025 19:35
Copy link

vercel bot commented Mar 18, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview Mar 18, 2025 7:35pm
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Mar 18, 2025 7:35pm

Comment on lines +62 to +71
enum ZlibErrorCodes {
Z_NEED_DICT = 2,
Z_STREAM_END = 1,
Z_ERRNO = -1,
Z_STREAM_ERROR = -2,
Z_DATA_ERROR = -3,
Z_MEM_ERROR = -4,
Z_BUF_ERROR = -5,
Z_VERSION_ERROR = -6,
}
Copy link
Member

Choose a reason for hiding this comment

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

Having these hardcoded here is not ideal.. Especially since zlib-sync exports each of these codes as constants

We could import them and construct this object using them
https://github.com/abalabahaha/zlib-sync/blob/7f1b404ba9e1bb9af1f47ca395f33e4fdfc2299c/src/zlib_sync.cc#L220-L228

(This would imply moving this object creation into the unpackMessage method as that's where zlib is being imported)

@Jiralite Jiralite added this to the ws 3.0.0 milestone May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

4 participants