Skip to content
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

+5 passing node:zlib tests #15944

Merged
merged 5 commits into from
Dec 23, 2024
Merged

+5 passing node:zlib tests #15944

merged 5 commits into from
Dec 23, 2024

Conversation

Jarred-Sumner
Copy link
Collaborator

@Jarred-Sumner Jarred-Sumner commented Dec 22, 2024

What does this PR do?

+5 passing node:zlib tests

  • This fixes a memory leak in node:zlib caused by keeping strong references to the callbacks and the this value when it wasn't necessary
  • This fixes the callbacks being associated with the wrong class (!)
  • This fixes a memory leak that could potentially occur where the stream was initialized but never freed (or never closed)

How did you verify your code works?

Ran existing node tests and verified they pass

@Jarred-Sumner Jarred-Sumner requested a review from nektro December 22, 2024 16:22
@robobun
Copy link

robobun commented Dec 22, 2024

Updated 10:12 AM PT - Dec 22nd, 2024

@Jarred-Sumner, your commit b77d569 has passed in #8423! 🎉


🧪   try this PR locally:

bunx bun-pr 15944

@Jarred-Sumner Jarred-Sumner changed the title +4 passing node:zlib tests +5 passing node:zlib tests Dec 22, 2024
Copy link
Member

@nektro nektro left a comment

Choose a reason for hiding this comment

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

nice

if (!common.isMainThread) {
common.skip('Cannot test the existence of --expose-internals from worker');
}
common.skip("This test is not going to be implemented in Bun. We do not support --expose-internals.")
Copy link
Member

@nektro nektro Dec 23, 2024

Choose a reason for hiding this comment

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

common.skip exits the process so the commenting out below here is unnecessary btw

@@ -662,16 +671,14 @@ pub const NativeBrotli = JSC.Codegen.JSNativeBrotli.getConstructor;

pub const SNativeBrotli = struct {
pub usingnamespace bun.NewRefCounted(@This(), deinit);
pub usingnamespace JSC.Codegen.JSNativeZlib;
pub usingnamespace JSC.Codegen.JSNativeBrotli;
Copy link
Member

@nektro nektro Dec 23, 2024

Choose a reason for hiding this comment

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

! nice find

Comment on lines +774 to +777
switch (this.stream.mode) {
.BROTLI_ENCODE, .BROTLI_DECODE => this.stream.close(),
else => {},
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
switch (this.stream.mode) {
.BROTLI_ENCODE, .BROTLI_DECODE => this.stream.close(),
else => {},
}
this.stream.close();

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's an assertion in there related to .mode so I was doing this to be cautious

@Jarred-Sumner Jarred-Sumner added this pull request to the merge queue Dec 23, 2024
@Jarred-Sumner Jarred-Sumner removed this pull request from the merge queue due to a manual request Dec 23, 2024
@Jarred-Sumner Jarred-Sumner merged commit 4f8a6b3 into main Dec 23, 2024
67 checks passed
@Jarred-Sumner Jarred-Sumner deleted the jarred/zlib-tests branch December 23, 2024 04:39
probably-neb pushed a commit to probably-neb/bun that referenced this pull request Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants