-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
node:zlib module has numerous bugs, inconsistencies, and errors #20516
Comments
It looks like all is needed here is some massaging of input types into the correct forms for the internal algorithms, and the right output types for the reverse. Sounds like a good first issue. @nberlette if you want to grab it, feel free, otherwise someone else can jump in (just remember to update on this issue if you are working on it as to not duplicate work!) |
Probably related: #20456 |
@lucacasonato Thanks for the reply Luca, I'll take a stab at it tonight! Based on your response it sounds like it should be pretty straihtforward to sort out. But forgive me in advance for any late-night pings you may get if I find myself lost in internal Deno-API-land 😅. @dsherret Thanks for bringing that issue in! Definitely seems to be related, thats some of the same behavior I've taken note of myself. I could swear I opened that issue up when I was searching for priors before making this post... I was in a rush though so I must've overlooked it. My bad. I'll cc you guys in the PR when I get it pushed through. Have a great weekend! |
Hey @lucacasonato, hope all is well. I've been progressing on a PR for the zlib module, but other unexpected commitments took priority the last couple weeks. Apologies for the delays. As this is my first real contribution here (aside from a few very small fixes in the past), I have a couple questions on aligning my changes with the codebase. Could you spare a few minutes to chat outside of GitHub, maybe via Discord or email? Thanks for your patience, |
This fixes point 2 of #20516 This adds a conversion from Dataview/Buffer by returning `obj.buffer` which can be converted to a `UInt8Array`. Question: Regarding point 4 of the mentioned issue would it be appropriate to copy the toU8 helper to the `zlib.mjs` methods?
This fixes point 3 of #20516 This PR creates consistency between the sync and async versions of the brotli compress where we will always return a buffer like Node.
Fixes #20516 Follow up to #21747 and #21746 This tackles the last point of #20516 where certain inputs weren't accepted in the other zlib methods This adds the `toU8` conversion of `_brotli` to `_zlib.mjs`, when we create the ZLibBuffer, we'll sanitize the input. I noticed that the async had no handler for `string` input so I added that as well.
This fixes point 2 of #20516 This adds a conversion from Dataview/Buffer by returning `obj.buffer` which can be converted to a `UInt8Array`. Question: Regarding point 4 of the mentioned issue would it be appropriate to copy the toU8 helper to the `zlib.mjs` methods?
This fixes point 3 of #20516 This PR creates consistency between the sync and async versions of the brotli compress where we will always return a buffer like Node.
Fixes #20516 Follow up to #21747 and #21746 This tackles the last point of #20516 where certain inputs weren't accepted in the other zlib methods This adds the `toU8` conversion of `_brotli` to `_zlib.mjs`, when we create the ZLibBuffer, we'll sanitize the input. I noticed that the async had no handler for `string` input so I added that as well.
I've noticed quite a few issues with the node:zlib implementation. Wasn't sure if I should open them up in individual issues, but decided to just do it unified since they're all related to the same module.
First off, I'd like to reference the official Node.js documentation on their zlib module. Note that the accepted input types by all convenience methods is
Buffer | TypedArray | DataView | ArrayBuffer | string
.brotli compression fails on data > 4096B(fixed in fix(ext/node/ops/zlib/brotli): Allow decompressing more than 4096 bytes #20301)zlib.brotliCompressSync
only accepts inputs that are Buffer, TypedArray, or string. It accepts all types of TypedArray, it seems, but DataViews and ArrayBuffers cause it to throw a vagueFailed to compress
exception. Inconsistent with the expected behavior above. See below for a screenshot.zlib.brotliCompress
returns what appears to be a native Uint8Array, rather than a Node.js Buffer like its synchronous counterpart. Definitely inconsistent behavior, and it gets more inconsistent when trying different input types. Any type other than a Buffer, string, or Uint8Array throws an error saying it "was not a typed ArrayBufferView".... which is not true. See below.I'd spend more time and document the behavior on each of the remaining methods but unfortunately I'm out of time right now. I'll try to follow this up with additional info and (hopefully) a PR, if I'm able to squeeze in a fix for this tonight/tomorrow.
Thanks!
The text was updated successfully, but these errors were encountered: