mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Match Node.js v24 behavior for napi_get_value_string_utf8 handling of NAPI_AUTO_LENGTH (#20698)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2098,12 +2098,6 @@ napi_status napi_get_value_string_any_encoding(napi_env env, napi_value napiValu
|
||||
return napi_set_last_error(env, napi_ok);
|
||||
}
|
||||
|
||||
if (bufsize == NAPI_AUTO_LENGTH) [[unlikely]] {
|
||||
if (writtenPtr) *writtenPtr = 0;
|
||||
buf[0] = '\0';
|
||||
return napi_set_last_error(env, napi_ok);
|
||||
}
|
||||
|
||||
size_t written;
|
||||
std::span<unsigned char> writable_byte_slice(reinterpret_cast<unsigned char*>(buf),
|
||||
EncodeTo == NapiStringEncoding::utf16
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { spawn, spawnSync } from "bun";
|
||||
import { beforeAll, describe, expect, it } from "bun:test";
|
||||
import { readdirSync } from "fs";
|
||||
import { bunEnv, bunExe, tempDirWithFiles } from "harness";
|
||||
import { bunEnv, bunExe, isCI, isMacOS, isMusl, tempDirWithFiles } from "harness";
|
||||
import { join } from "path";
|
||||
|
||||
describe("napi", () => {
|
||||
@@ -185,9 +185,10 @@ describe("napi", () => {
|
||||
expect(result).toEndWith("str: abcdef");
|
||||
});
|
||||
|
||||
it.todo("copies auto len", async () => {
|
||||
// TODO: once we upgrade the Node version on macOS and musl to Node v24.3.0, remove this TODO
|
||||
it.todoIf(isCI && (isMacOS || isMusl))("copies auto len", async () => {
|
||||
const result = await checkSameOutput("test_napi_get_value_string_utf8_with_buffer", ["abcdef", 424242]);
|
||||
expect(result).toEndWith("str:");
|
||||
expect(result).toEndWith("str: abcdef");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user