Compare commits

...

4 Commits

Author SHA1 Message Date
RiskyMH
5e6b84c68c deps: update libarchive to v3.8.3 (1368b08875351df8aa268237b882c8f4ceb0882d) 2025-11-30 03:32:56 +00:00
Dylan Conway
cc3fc5a1d3 fix ENG-24015 (#25222)
### What does this PR do?
Ensures `ptr` is either a number or heap big int before converting to a
number.

also fixes ENG-24039
### How did you verify your code works?
Added a test
2025-11-29 19:13:32 -08:00
Dylan Conway
d83e0eb1f1 fix ENG-24017 (#25224)
### What does this PR do?
Fixes checking for exceptions when creating empty or used readable
streams

also fixes ENG-24038
### How did you verify your code works?
Added a test for creating empty streams
2025-11-29 19:13:06 -08:00
Dylan Conway
72b9525507 update bunfig telemetry docs (#25237)
### What does this PR do?

### How did you verify your code works?
2025-11-29 19:12:18 -08:00
8 changed files with 45 additions and 12 deletions

View File

@@ -4,7 +4,7 @@ register_repository(
REPOSITORY
libarchive/libarchive
COMMIT
9525f90ca4bd14c7b335e2f8c84a4607b0af6bdf
1368b08875351df8aa268237b882c8f4ceb0882d
)
register_cmake_command(

View File

@@ -107,7 +107,9 @@ Bun supports the following loaders:
### `telemetry`
The `telemetry` field permit to enable/disable the analytics records. Bun records bundle timings (so we can answer with data, "is Bun getting faster?") and feature usage (e.g., "are people actually using macros?"). The request body size is about 60 bytes, so it's not a lot of data. By default the telemetry is enabled. Equivalent of `DO_NOT_TRACK` env variable.
The `telemetry` field is used to enable/disable analytics. By default, telemetry is enabled. This is equivalent to the `DO_NOT_TRACK` environment variable.
Currently we do not collect telemetry and this setting is only used for enabling/disabling anonymous crash reports, but in the future we plan to collect information like which Bun APIs are used most or how long `bun build` takes.
```toml title="bunfig.toml" icon="settings"
telemetry = false

View File

@@ -1360,7 +1360,7 @@ pub const FFI = struct {
const num = ptr.asPtrAddress();
if (num > 0)
function.symbol_from_dynamic_library = @as(*anyopaque, @ptrFromInt(num));
} else {
} else if (ptr.isHeapBigInt()) {
const num = ptr.toUInt64NoTruncate();
if (num > 0) {
function.symbol_from_dynamic_library = @as(*anyopaque, @ptrFromInt(num));

View File

@@ -1156,10 +1156,11 @@ pub const JSValue = enum(i64) {
return JSC__JSValue__bigIntSum(globalObject, a, b);
}
extern fn JSC__JSValue__toUInt64NoTruncate(this: JSValue) u64;
/// Value must be either `isHeapBigInt` or `isNumber`
pub fn toUInt64NoTruncate(this: JSValue) u64 {
return JSC__JSValue__toUInt64NoTruncate(this);
}
extern fn JSC__JSValue__toUInt64NoTruncate(this: JSValue) u64;
/// Deprecated: replace with 'toBunString'
pub fn getZigString(this: JSValue, global: *JSGlobalObject) bun.JSError!ZigString {

View File

@@ -2916,20 +2916,26 @@ JSC::EncodedJSValue JSC__JSModuleLoader__evaluate(JSC::JSGlobalObject* globalObj
}
}
JSC::EncodedJSValue ReadableStream__empty(Zig::GlobalObject* globalObject)
[[ZIG_EXPORT(zero_is_throw)]] JSC::EncodedJSValue ReadableStream__empty(Zig::GlobalObject* globalObject)
{
auto& vm = JSC::getVM(globalObject);
auto scope = DECLARE_THROW_SCOPE(vm);
auto clientData = WebCore::clientData(vm);
auto* function = globalObject->getDirect(vm, clientData->builtinNames().createEmptyReadableStreamPrivateName()).getObject();
return JSValue::encode(JSC::call(globalObject, function, JSC::ArgList(), "ReadableStream.create"_s));
JSValue emptyStream = JSC::call(globalObject, function, JSC::ArgList(), "ReadableStream.create"_s);
RETURN_IF_EXCEPTION(scope, {});
return JSValue::encode(emptyStream);
}
JSC::EncodedJSValue ReadableStream__used(Zig::GlobalObject* globalObject)
[[ZIG_EXPORT(zero_is_throw)]] JSC::EncodedJSValue ReadableStream__used(Zig::GlobalObject* globalObject)
{
auto& vm = JSC::getVM(globalObject);
auto scope = DECLARE_THROW_SCOPE(vm);
auto clientData = WebCore::clientData(vm);
auto* function = globalObject->getDirect(vm, clientData->builtinNames().createUsedReadableStreamPrivateName()).getObject();
return JSValue::encode(JSC::call(globalObject, function, JSC::ArgList(), "ReadableStream.create"_s));
JSValue usedStream = JSC::call(globalObject, function, JSC::ArgList(), "ReadableStream.create"_s);
RETURN_IF_EXCEPTION(scope, {});
return JSValue::encode(usedStream);
}
JSC::EncodedJSValue JSC__JSValue__createRangeError(const ZigString* message, const ZigString* arg1,

View File

@@ -391,13 +391,12 @@ pub fn fromPipe(
pub fn empty(globalThis: *JSGlobalObject) bun.JSError!jsc.JSValue {
jsc.markBinding(@src());
return bun.jsc.fromJSHostCall(globalThis, @src(), ReadableStream__empty, .{globalThis});
return bun.cpp.ReadableStream__empty(globalThis);
}
pub fn used(globalThis: *JSGlobalObject) jsc.JSValue {
pub fn used(globalThis: *JSGlobalObject) bun.JSError!jsc.JSValue {
jsc.markBinding(@src());
return ReadableStream__used(globalThis);
return bun.cpp.ReadableStream__used(globalThis);
}
pub const StreamTag = enum(usize) {

View File

@@ -62,4 +62,15 @@ describe("FFI error messages", () => {
});
}).toThrow(/myFunction.*ptr.*(linkSymbols|CFunction)/);
});
test("linkSymbols with non-number ptr does not crash", () => {
expect(() => {
linkSymbols({
fn: {
// @ts-expect-error
ptr: "not a number",
},
});
}).toThrow('you must provide a "ptr" field with the memory address of the native function.');
});
});

View File

@@ -1191,3 +1191,17 @@ recursiveFunction();
expect(exitCode).toBe(0);
});
it("handles exceptions during empty stream creation", () => {
expect(() => {
function foo() {
try {
foo();
} catch (e) {}
const v8 = new Blob();
v8.stream();
}
foo();
throw new Error("not stack overflow");
}).toThrow("not stack overflow");
});