mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
## Summary
- Fixed crypto.hkdf callback to pass `null` instead of `undefined` for
the error parameter on success
- Added regression test to verify the fix
## Details
Fixes #23211
Node.js convention requires crypto callbacks to receive `null` as the
error parameter on success, but Bun was passing `undefined`. This caused
compatibility issues with code that relies on strict null checks (e.g.,
[matter.js](fdbec2cf88/packages/general/src/crypto/NodeJsStyleCrypto.ts (L169))).
### Changes
- Updated `CryptoHkdf.cpp` to pass `jsNull()` instead of `jsUndefined()`
for the error parameter in the success callback
- Added regression test in `test/regression/issue/23211.test.ts`
## Test plan
- [x] Added regression test that verifies callback receives `null` on
success
- [x] Test passes with the fix
- [x] Ran existing crypto tests (no failures)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
// https://github.com/oven-sh/bun/issues/23183
|
|
// Test that accessing process.title doesn't crash on Windows
|
|
import { expect, test } from "bun:test";
|
|
import { bunEnv, bunExe, isWindows } from "harness";
|
|
|
|
test("process.title should not crash on Windows", async () => {
|
|
const proc = Bun.spawn({
|
|
cmd: [bunExe(), "-e", "console.log(typeof process.title)"],
|
|
env: bunEnv,
|
|
stdout: "pipe",
|
|
stderr: "pipe",
|
|
});
|
|
|
|
const [stdout, stderr, exitCode] = await Promise.all([
|
|
Bun.readableStreamToText(proc.stdout),
|
|
Bun.readableStreamToText(proc.stderr),
|
|
proc.exited,
|
|
]);
|
|
|
|
expect(stderr).toBe("");
|
|
expect(exitCode).toBe(0);
|
|
expect(stdout.trim()).toBe("string");
|
|
});
|
|
|
|
test("process.title should return a non-empty string or fallback to 'bun'", async () => {
|
|
const proc = Bun.spawn({
|
|
cmd: [bunExe(), "-e", "console.log(process.title)"],
|
|
env: bunEnv,
|
|
stdout: "pipe",
|
|
stderr: "pipe",
|
|
});
|
|
|
|
const [stdout, stderr, exitCode] = await Promise.all([
|
|
Bun.readableStreamToText(proc.stdout),
|
|
Bun.readableStreamToText(proc.stderr),
|
|
proc.exited,
|
|
]);
|
|
|
|
expect(stderr).toBe("");
|
|
expect(exitCode).toBe(0);
|
|
const title = stdout.trim();
|
|
expect(title.length).toBeGreaterThan(0);
|
|
if (isWindows) {
|
|
// On Windows, we should get either a valid console title or "bun"
|
|
expect(typeof title).toBe("string");
|
|
} else {
|
|
expect(title).toBe("bun");
|
|
}
|
|
});
|