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

Return expected data when using Promises with crypto.generateKeyPair #13600

Merged
merged 3 commits into from
Aug 31, 2024

Conversation

wpaulino
Copy link
Contributor

What does this PR do?

It enables the use of util.promisify with crypto.generateKeyPair by properly returning the expected data. Previously, we'd only ever handle the first argument of the callback, hence why the public key would always get returned on its own.

There are a couple other functions that could use the same work in other parts of the node library, but that can be left for follow-up work.

How did you verify your code works?

  • I included a test for the new code, or existing tests cover it
  • I ran my tests locally and they pass (bun-debug test test-file-name.test)

Fixes #9469.

@@ -133,6 133,16 @@ const {
Uint8Array,
} = primordials;

const kCustomPromisifyArgsSymbol = Symbol('customPromisifyArgs');
Copy link
Collaborator

Choose a reason for hiding this comment

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

This util/inspect.js file is 92 KB of JS

Please move this function into a separate file, so that it can be lazily loaded without loading all of util/inspect.js

image

Copy link
Collaborator

Choose a reason for hiding this comment

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

edit: it looks like we are already loading this file in util.js

so it's probably fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it was worth refactoring anyway, let me know if you disagree and I can revert/amend it.


const callbackArgs = original[kCustomPromisifyArgsSymbol];

function fn(...originalArgs) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

instead of checking for callbackArgs on every call

this should return a different function which handles the callbackArgs and a function which does not handle them

Copy link
Collaborator

@Jarred-Sumner Jarred-Sumner Aug 30, 2024

Choose a reason for hiding this comment

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

though i see that this implementation wasn't changed much from before

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah this whole commit is just moving code around, no change in behavior.

@Jarred-Sumner
Copy link
Collaborator

lets merge once it builds successfully

@wpaulino
Copy link
Contributor Author


[3.76s] Bundled "src/js" for production
--
  | 1671 kb
  | 74 internal modules
  | 351 internal functions across 31 files
  | [36/37] cd /opt/homebrew/var/buildkite-agent/builds/darwin-aarch64-studio-1/bun/bun/build && /opt/homebrew/var/buildkite-agent/builds/darwin-aarch64-studio-1/bun/bun/.cache/zig/zig run --zig-lib-dir /opt/homebrew/var/buildkite-agent/builds/darwin-aarch64-studio-1/bun/bun/src/deps/zig/lib --cache-dir /opt/homebrew/var/buildkite-agent/builds/darwin-aarch64-studio-1/bun/bun/build/zig-cache/local --global-cache-dir /opt/homebrew/var/buildkite-agent/builds/darwin-aarch64-studio-1/bun/bun/build/zig-cache/global /opt/homebrew/var/buildkite-agent/builds/darwin-aarch64-studio-1/bun/bun/src/js_lexer/identifier_data.zig

Did CI just give up mid-build? They all stopped there. It builds fine for me locally.

@Jarred-Sumner Jarred-Sumner merged commit 76c4145 into oven-sh:main Aug 31, 2024
42 of 45 checks passed
@wpaulino wpaulino deleted the promise-generate-keypair branch August 31, 2024 03:22
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.

Promisified crypto.generateKeyPair does not fulfill the resolve value specified in the Nodejs document
2 participants