From f02013ef7ea5c16216fb24d2c0b0b290efb59f08 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Fri, 17 Oct 2025 23:11:16 -0700 Subject: [PATCH] some more --- scripts/utils.mjs | 8 ++++++++ src/bun.js/api/BunObject.zig | 8 +------- src/bun.js/api/server/ServerConfig.zig | 7 +++---- src/bun.js/bindings/ZigGlobalObject.cpp | 4 +--- src/bun.js/webcore/Blob.zig | 6 ++---- src/bun.js/webcore/ReadableStream.zig | 2 +- src/http/websocket_client.zig | 8 +------- src/valkey/js_valkey.zig | 4 ++-- src/valkey/js_valkey_functions.zig | 2 +- test/leaksan.supp | 5 +++++ 10 files changed, 25 insertions(+), 29 deletions(-) diff --git a/scripts/utils.mjs b/scripts/utils.mjs index 604227f9cd..ed7c3ba5e7 100755 --- a/scripts/utils.mjs +++ b/scripts/utils.mjs @@ -2679,6 +2679,14 @@ export function reportAnnotationToBuildKite({ context, label, content, style = " if (!isBuildkite) { return; } + + // https://buildkite.com/docs/agent/v3/cli-annotate + // > The annotation body can be supplied as a command line argument, or by piping content into the command. The maximum size of each annotation body is 1MiB. + if (content.length > 1024 * 32) { + content = content.slice(content.length - 1024 * 32); // trim to the last 32kb of the message + content = content.slice(content.indexOf("\n")); // don't cutoff in the middle of a line + } + const { error, status, signal, stderr } = nodeSpawnSync( "buildkite-agent", ["annotate", "--append", "--style", `${style}`, "--context", `${context || label}`, "--priority", `${priority}`], diff --git a/src/bun.js/api/BunObject.zig b/src/bun.js/api/BunObject.zig index ea3562fc9b..8ef2ee5314 100644 --- a/src/bun.js/api/BunObject.zig +++ b/src/bun.js/api/BunObject.zig @@ -1306,13 +1306,7 @@ pub fn getValkeyDefaultClient(globalThis: *jsc.JSGlobalObject, _: *jsc.JSObject) const as_js = valkey.toJS(globalThis); valkey.this_value = jsc.JSRef.initWeak(as_js); - valkey._subscription_ctx = SubscriptionCtx.init(valkey) catch |err| { - if (err != error.JSError) { - _ = globalThis.throwError(err, "Failed to create Redis client") catch {}; - return .zero; - } - return .zero; - }; + valkey._subscription_ctx = SubscriptionCtx.init(valkey); return as_js; } diff --git a/src/bun.js/api/server/ServerConfig.zig b/src/bun.js/api/server/ServerConfig.zig index 8a1caca83d..ca6e86a725 100644 --- a/src/bun.js/api/server/ServerConfig.zig +++ b/src/bun.js/api/server/ServerConfig.zig @@ -246,16 +246,15 @@ pub fn applyStaticRoute(server: AnyServer, comptime ssl: bool, app: *uws.NewApp( pub fn deinit(this: *ServerConfig) void { this.address.deinit(bun.default_allocator); + bun.default_allocator.free(this.base_uri); + this.base_uri = ""; + this.base_url = .{}; for (this.negative_routes.items) |route| { bun.default_allocator.free(route); } this.negative_routes.clearAndFree(); - if (this.base_url.href.len > 0) { - bun.default_allocator.free(this.base_url.href); - this.base_url = URL{}; - } if (this.ssl_config) |*ssl_config| { ssl_config.deinit(); this.ssl_config = null; diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 0d0a5b5cfc..1931db676c 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -3408,9 +3408,7 @@ static JSC::JSPromise* handleResponseOnStreamingAction(JSGlobalObject* lexicalGl // getBodyStreamOrBytesForWasmStreaming throws the proper exception. Since this is being // executed in a .then(...) callback, throwing is perfectly fine. - auto readableStreamMaybe = JSC::JSValue::decode(Zig__GlobalObject__getBodyStreamOrBytesForWasmStreaming( - globalObject, JSC::JSValue::encode(source), compiler.ptr())); - + auto readableStreamMaybe = JSC::JSValue::decode(Zig__GlobalObject__getBodyStreamOrBytesForWasmStreaming(globalObject, JSC::JSValue::encode(source), compiler.ptr())); RETURN_IF_EXCEPTION(scope, nullptr); // We were able to get the slice synchronously. diff --git a/src/bun.js/webcore/Blob.zig b/src/bun.js/webcore/Blob.zig index 56cd96f1f0..31c4228701 100644 --- a/src/bun.js/webcore/Blob.zig +++ b/src/bun.js/webcore/Blob.zig @@ -3268,10 +3268,7 @@ pub fn createWithBytesAndAllocator( ) Blob { return Blob{ .size = @as(SizeType, @truncate(bytes.len)), - .store = if (bytes.len > 0) - Blob.Store.init(bytes, allocator) - else - null, + .store = if (bytes.len > 0) Blob.Store.init(bytes, allocator) else null, .content_type = if (was_string) MimeType.text.value else "", .globalThis = globalThis, }; @@ -3405,6 +3402,7 @@ pub fn deinit(this: *Blob) void { this.name.deref(); this.name = .dead; if (this.content_type_allocated) bun.default_allocator.free(this.content_type); + if (this.store) |store| store.deref(); if (this.isHeapAllocated()) { bun.destroy(this); diff --git a/src/bun.js/webcore/ReadableStream.zig b/src/bun.js/webcore/ReadableStream.zig index d7b3b22195..450217d335 100644 --- a/src/bun.js/webcore/ReadableStream.zig +++ b/src/bun.js/webcore/ReadableStream.zig @@ -778,7 +778,7 @@ pub fn NewSource( jsc.markBinding(@src()); this.this_jsvalue = callFrame.this(); var list = this.drain(); - defer list.deinit(bun.default_allocator); + // defer list.deinit(bun.default_allocator); if (list.len > 0) { return jsc.ArrayBuffer.fromBytes(list.slice(), .Uint8Array).toJS(globalThis); } diff --git a/src/http/websocket_client.zig b/src/http/websocket_client.zig index b340b8fc56..6d26887bb1 100644 --- a/src/http/websocket_client.zig +++ b/src/http/websocket_client.zig @@ -1174,13 +1174,7 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { } } - if (!Socket.adoptPtr( - tcp, - ctx, - WebSocket, - "tcp", - ws, - )) { + if (!Socket.adoptPtr(tcp, ctx, WebSocket, "tcp", ws)) { ws.deref(); return null; } diff --git a/src/valkey/js_valkey.zig b/src/valkey/js_valkey.zig index 24f77d2648..54f82e66ff 100644 --- a/src/valkey/js_valkey.zig +++ b/src/valkey/js_valkey.zig @@ -7,7 +7,7 @@ pub const SubscriptionCtx = struct { const ParentJS = JSValkeyClient.js; - pub fn init(valkey_parent: *JSValkeyClient) bun.JSError!Self { + pub fn init(valkey_parent: *JSValkeyClient) Self { const callback_map = jsc.JSMap.create(valkey_parent.globalObject); const parent_this = valkey_parent.this_value.tryGet() orelse unreachable; @@ -388,7 +388,7 @@ pub const JSValkeyClient = struct { new_client.this_value = jsc.JSRef.initWeak(js_this); // Need to associate the subscription context, after the JS ref has been populated. - new_client._subscription_ctx = try SubscriptionCtx.init(new_client); + new_client._subscription_ctx = SubscriptionCtx.init(new_client); return new_client; } diff --git a/src/valkey/js_valkey_functions.zig b/src/valkey/js_valkey_functions.zig index c3f4f9e1d5..7ae3dee39e 100644 --- a/src/valkey/js_valkey_functions.zig +++ b/src/valkey/js_valkey_functions.zig @@ -1264,7 +1264,7 @@ pub fn duplicate( const new_client_js = new_client.toJS(globalObject); new_client.this_value = jsc.JSRef.initWeak(new_client_js); - new_client._subscription_ctx = try SubscriptionCtx.init(new_client); + new_client._subscription_ctx = SubscriptionCtx.init(new_client); // If the original client is already connected and not manually closed, start connecting the new client. if (this.client.status == .connected and !this.client.flags.is_manually_closed) { // Use strong reference during connection to prevent premature GC diff --git a/test/leaksan.supp b/test/leaksan.supp index b7f431ff26..ef6c2e03cb 100644 --- a/test/leaksan.supp +++ b/test/leaksan.supp @@ -199,3 +199,8 @@ leak:interchange.json.parsePackageJSONUTF8 leak:bundler. leak:http.cloneMetadata leak:bun.js.rare_data.AWSSignatureCache.set +leak:shell. +leak:bun.js.webcore.blob.Store.init +leak:bun.js.webcore.ByteBlobLoader.drain +leak:bun.js.node.path.dirnamePosixJS_T__anon +leak:bun.js.test.bun_test.BunTest.ref