From ee4ef397751d2c814f037a7734bfa908b5a9b64f Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Sun, 27 Sep 2026 03:22:42 +0000 Subject: [PATCH] Remove dead code from bun init, bun create, bun_md, bun_install, and the socket and Postgres code Each group cannot run, or holds a value that nothing reads. No lint reports them, because each still has a textual user: an unreachable call, a store, or a parameter that every caller sets to one value. - bun init: the React dependency tables and the code that wrote a `dependencies` object. `exec` returns early for the React templates. - bun create: `CreateListExamplesCommand` (the help text exits first), the `Option` of `Example::print`, the progress node parameter of `fetch_all_local_and_remote` and `fetch_all`, and three constant locals with the hints they guarded. - bun_md: the first ATX trim block in `analyze_line` (`line.end` is 0 there) and two branches of `is_container_compatible` that do not change its result. - bun_install: `Subcommand::Pack` and `PACK_PARAMS`. `bun pm pack` runs as `Subcommand::Pm`. - Sockets: `Flags::OWNED_PROTOS`, which only guarded a store of `None` right before a store of the new value. - Postgres: the map `backend_parameters`, which nothing reads. - bun_ast, bun_js_parser: `Ast.runtime_imports`, which nothing reads. - `src/jsc/bindings/JSCInlines.h`, which no include reaches. --- src/ast/ast_result.rs | 3 - src/install/PackageManager.rs | 1 - .../PackageManager/CommandLineArguments.rs | 42 +-- src/js_parser/p.rs | 6 - src/jsc/bindings/JSCInlines.h | 57 ---- src/md/autolinks.rs | 4 - src/md/blocks.rs | 26 -- src/md/containers.rs | 16 +- src/runtime/cli/create_command.rs | 110 +------ src/runtime/cli/init_command.rs | 268 +----------------- src/runtime/socket/Listener.rs | 7 - src/runtime/socket/socket_body.rs | 12 +- src/sql_jsc/postgres/PostgresSQLConnection.rs | 18 +- 13 files changed, 20 insertions(+), 550 deletions(-) delete mode 100644 src/jsc/bindings/JSCInlines.h diff --git a/src/ast/ast_result.rs b/src/ast/ast_result.rs index dcc3b920b894..0b09f8717c71 100644 --- a/src/ast/ast_result.rs +++ b/src/ast/ast_result.rs @@ -8,7 +8,6 @@ use bun_alloc::{AstAlloc, AstVec}; use bun_collections::array_hash_map::{AutoContext, StringContext}; use bun_collections::{ArrayHashMap, StringArrayHashMap, StringHashMap}; -use crate::runtime; use crate::{ CharFreq, ExportsKind, Expr, InlinedEnumValue, LocRef, NamedExport, NamedImport, Part, Range, Ref, Scope, SlotCounts, StoreStr, Target, @@ -23,7 +22,6 @@ pub type TopLevelSymbolToParts = ArrayHashMap, AutoContext, Ast pub struct Ast<'a> { pub approximate_newline_count: usize, pub has_lazy_export: bool, - pub runtime_imports: runtime::Imports, pub nested_scope_slot_counts: SlotCounts, @@ -111,7 +109,6 @@ impl<'a> Ast<'a> { Self { approximate_newline_count: 0, has_lazy_export: false, - runtime_imports: Default::default(), nested_scope_slot_counts: SlotCounts::default(), uses_exports_ref: false, uses_module_ref: false, diff --git a/src/install/PackageManager.rs b/src/install/PackageManager.rs index 49e49cb8a7ac..b41bb8dce4e0 100644 --- a/src/install/PackageManager.rs +++ b/src/install/PackageManager.rs @@ -500,7 +500,6 @@ pub enum Subcommand { #[strum(serialize = "patch-commit")] PatchCommit, Outdated, - Pack, Publish, Audit, Info, diff --git a/src/install/PackageManager/CommandLineArguments.rs b/src/install/PackageManager/CommandLineArguments.rs index a8c85d407869..97bdea1a7582 100644 --- a/src/install/PackageManager/CommandLineArguments.rs +++ b/src/install/PackageManager/CommandLineArguments.rs @@ -374,21 +374,6 @@ static INFO_PARAMS: &[ParamType] = concat_params![ ] ]; -static PACK_PARAMS: &[ParamType] = concat_params![ - SHARED_PARAMS, - &[ - // clap::param!("--filter ... Pack each matching workspace"), - clap::param!( - "--destination The directory the tarball will be saved in" - ), - clap::param!("--filename The filename of the tarball"), - clap::param!( - "--gzip-level Specify a custom compression level for gzip. Default is 9." - ), - clap::param!(" ... "), - ] -]; - static PUBLISH_PARAMS: &[ParamType] = concat_params![ SHARED_PARAMS, &[ @@ -1025,27 +1010,6 @@ Full documentation is available at https://bun.com/docs/cli/outdated pretty_help(outro_text); Output::flush(); } - Subcommand::Pack => { - let intro_text = r" -Usage: bun pm pack [flags] - - Create a tarball for the current project. - -Flags:"; - - let outro_text = r" - -Examples: - bun pm pack - -Full documentation is available at https://bun.com/docs/cli/pm#pack. -"; - - pretty_help(intro_text); - clap::simple_help(PACK_PARAMS); - pretty_help(outro_text); - Output::flush(); - } Subcommand::Publish => { let intro_text = r" Usage: bun publish [flags] [dist] @@ -1242,7 +1206,6 @@ Full documentation is available at https://bun.com/docs/pm/cli/prune Subcommand::Patch => PATCH_PARAMS, Subcommand::PatchCommit => PATCH_COMMIT_PARAMS, Subcommand::Outdated => OUTDATED_PARAMS, - Subcommand::Pack => PACK_PARAMS, Subcommand::Publish => PUBLISH_PARAMS, Subcommand::Why => WHY_PARAMS, Subcommand::Dedupe => DEDUPE_PARAMS, @@ -1422,10 +1385,7 @@ Full documentation is available at https://bun.com/docs/pm/cli/prune cli.dry_run = true; } - if matches!( - subcommand, - Subcommand::Pack | Subcommand::Pm | Subcommand::Publish - ) { + if matches!(subcommand, Subcommand::Pm | Subcommand::Publish) { if subcommand != Subcommand::Publish { if let Some(dest) = args.option(b"--destination") { cli.pack_destination = dest; diff --git a/src/js_parser/p.rs b/src/js_parser/p.rs index 2383804eb65e..8382934a310e 100644 --- a/src/js_parser/p.rs +++ b/src/js_parser/p.rs @@ -9410,16 +9410,11 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O self.symbols[self.require_ref.inner_index() as usize].use_count_estimate > 0 }; - // Move the - // parser's accumulated runtime-helper refs into the Ast so the linker / - // printer can emit `__require`, `__toESM`, etc. Precompute `require_ref` - // first since it reads `__require` from the same struct we're taking. let require_ref = self .runtime_imports .__require .to_nullable() .unwrap_or(self.require_ref); - let runtime_imports = core::mem::take(&mut self.runtime_imports); if !self.commonjs_named_exports_deoptimized { self.mark_commonjs_exports_that_ignore_this(); @@ -9444,7 +9439,6 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O // returned up the `_parse → parse → cache → transpiler` chain (see // `js_parser::Result` PERF NOTE). Ok(Box::new(js_ast::Ast { - runtime_imports, module_scope, exports_ref: self.exports_ref, wrapper_ref, diff --git a/src/jsc/bindings/JSCInlines.h b/src/jsc/bindings/JSCInlines.h deleted file mode 100644 index 1e4910c3d554..000000000000 --- a/src/jsc/bindings/JSCInlines.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2014-2017 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -// This file's only purpose is to collect commonly used *Inlines.h files, so that you don't -// have to include all of them in every .cpp file. Instead you just include this. It's good -// style to make sure that every .cpp file includes JSCInlines.h. -// -// JSC should never include this file, or any *Inline.h file, from interface headers, since -// this could lead to a circular dependency. -// -// WebCore, or any other downstream client of JSC, is allowed to include this file in headers. -// In fact, it can make a lot of sense: outside of JSC, this file becomes a kind of umbrella -// header that pulls in most (all?) of the interesting things in JSC. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include diff --git a/src/md/autolinks.rs b/src/md/autolinks.rs index 1ebc58871d03..c3c873308705 100644 --- a/src/md/autolinks.rs +++ b/src/md/autolinks.rs @@ -1,10 +1,6 @@ use crate::helpers; use crate::inlines::EmphDelim; -pub(crate) fn is_list_bullet(c: u8) -> bool { - c == b'-' || c == b'+' || c == b'*' -} - pub(crate) fn is_list_item_mark(c: u8) -> bool { c == b'-' || c == b'+' || c == b'*' || c == b'.' || c == b')' } diff --git a/src/md/blocks.rs b/src/md/blocks.rs index dedea9e7d824..1307815febd4 100644 --- a/src/md/blocks.rs +++ b/src/md/blocks.rs @@ -447,32 +447,6 @@ impl Parser<'_> { line.r#type = LineType::Atxheader; line.data = atx_result.level; line.beg = atx_result.content_beg; - - // Trim trailing whitespace - while line.end > line.beg - && (helpers::is_blank(self.text[(line.end - 1) as usize]) - || self.text[(line.end - 1) as usize] == b'\t') - { - line.end -= 1; - } - // Trim optional closing # sequence - if line.end > line.beg && self.text[(line.end - 1) as usize] == b'#' { - let mut tmp = line.end; - while tmp > line.beg && self.text[(tmp - 1) as usize] == b'#' { - tmp -= 1; - } - // The closing # must be preceded by space (or be the entire content) - if tmp == line.beg || helpers::is_blank(self.text[(tmp - 1) as usize]) { - line.end = tmp; - // Trim trailing whitespace again - while line.end > line.beg - && helpers::is_blank(self.text[(line.end - 1) as usize]) - { - line.end -= 1; - } - } - } - break; } } diff --git a/src/md/containers.rs b/src/md/containers.rs index 6c500200a125..59d41ee054bd 100644 --- a/src/md/containers.rs +++ b/src/md/containers.rs @@ -2,7 +2,6 @@ use core::mem::{align_of, size_of}; use bun_alloc::AllocError; -use crate::autolinks::is_list_bullet; use crate::parser::{self, BlockHeader, Parser}; use crate::types::{self, BlockType, Container, VerbatimLine}; @@ -157,19 +156,8 @@ impl Parser<'_> { pub(crate) fn is_container_compatible(&self, existing: &Container, new: &Container) -> bool { let _ = self; - // Same container type - if existing.ch == b'>' && new.ch == b'>' { - return true; - } - // Same list marker type - if existing.ch == new.ch { - return true; - } - // Bullet lists: different bullet chars are compatible - if is_list_bullet(existing.ch) && is_list_bullet(new.ch) { - return false; - } - false + // Two block quotes, or two list items with the same marker. + existing.ch == new.ch } pub(crate) fn process_all_blocks(&mut self) -> Result<(), parser::Error> { diff --git a/src/runtime/cli/create_command.rs b/src/runtime/cli/create_command.rs index 9c8214daee11..bc37c1c9e963 100644 --- a/src/runtime/cli/create_command.rs +++ b/src/runtime/cli/create_command.rs @@ -272,10 +272,6 @@ impl CreateCommand { let mut create_options = CreateOptions::parse(ctx)?; let positionals = &create_options.positionals; - if positionals.is_empty() { - return CreateListExamplesCommand::exec(ctx); - } - // SAFETY: `fs::FileSystem::init` returns a process-global singleton pointer. let filesystem: &mut fs::FileSystem = unsafe { &mut *fs::FileSystem::init(None)? }; let mut env_loader = DotEnv::Loader::init(); @@ -302,8 +298,7 @@ impl CreateCommand { // `Progress::start` returns // `&mut Node` borrowing `progress` exclusively for the node's lifetime. // Convert to `*mut` immediately so `progress` and `node` can be used - // independently below (same pattern as `CreateListExamplesCommand::exec` - // at the bottom of this file). + // independently below. let node: *mut ProgressNode = match example_tag { ExampleTag::JslikeFile => progress.start( ProgressBuf::print(format_args!("Analyzing {}", bstr::BStr::new(template)))?, @@ -368,11 +363,10 @@ impl CreateCommand { let examples = Example::fetch_all_local_and_remote( ctx, - None, &mut env_loader, filesystem, )?; - Example::print(&examples, Some(dirname)); + Example::print(&examples, dirname); Global::exit(1); } else { node.end(); @@ -431,11 +425,10 @@ impl CreateCommand { let examples = Example::fetch_all_local_and_remote( ctx, - None, &mut env_loader, filesystem, )?; - Example::print(&examples, Some(dirname)); + Example::print(&examples, dirname); Global::crash(); } else { node.end(); @@ -735,9 +728,6 @@ impl CreateCommand { node.end(); progress.refresh(); - let is_nextjs = false; - let is_create_react_app = false; - let create_react_app_entry_point_path: &[u8] = b""; let mut preinstall_tasks: Vec<&[u8]> = Vec::new(); let mut postinstall_tasks: Vec<&[u8]> = Vec::new(); let mut has_dependencies: bool = false; @@ -1216,17 +1206,6 @@ impl CreateCommand { ); } - if is_nextjs { - bun_core::pretty!( - "\n# When dependencies change, run this to update node_modules.bun:\n\n bun bun --use next\n", - ); - } else if is_create_react_app { - bun_core::pretty!( - "\n# When dependencies change, run this to update node_modules.bun:\n\n bun bun {}\n", - bstr::BStr::new(create_react_app_entry_point_path), - ); - } - // `bun_resolver::fs::FileSystem` (the inline shim) has no `relative_to`; call // the resolver path helper directly with the singleton's `top_level_dir`. let rel_destination = @@ -1709,7 +1688,6 @@ impl ExampleTag { // RacyCell. `URL_` borrows into the `*_BUF` statics so they must remain // process-lifetime, not stack locals. static URL_: bun_core::RacyCell>> = bun_core::RacyCell::new(None); -static APP_NAME_BUF: bun_core::RacyCell<[u8; 512]> = bun_core::RacyCell::new([0u8; 512]); static GITHUB_REPOSITORY_URL_BUF: bun_core::RacyCell<[u8; 1024]> = bun_core::RacyCell::new([0u8; 1024]); // Static so the borrowed slice satisfies `URL<'static>` for @@ -1720,23 +1698,8 @@ static NPM_REGISTRY_URL_BUF: bun_core::RacyCell<[u8; 1024]> = bun_core::RacyCell impl Example { const EXAMPLES_URL: &'static [u8] = b"https://registry.npmjs.org/bun-examples-all/latest"; - pub(crate) fn print(examples: &[Example], default_app_name: Option<&[u8]>) { + pub(crate) fn print(examples: &[Example], app_name: &[u8]) { for example in examples { - // SAFETY: single-threaded CLI access to static buffer - let app_name_buf = unsafe { &mut *APP_NAME_BUF.get() }; - let app_name: &[u8] = default_app_name.unwrap_or_else(|| { - let mut cursor: &mut [u8] = &mut app_name_buf[..]; - let cap = cursor.len(); - write!( - &mut cursor, - "./{}-app", - bstr::BStr::new(&example.name[0..example.name.len().min(492)]) - ) - .expect("unreachable"); - let written = cap - cursor.len(); - &app_name_buf[..written] - }); - if !example.description.is_empty() { bun_core::pretty!( " # {}\n bun create {} {}\n \n\n", @@ -1756,14 +1719,10 @@ impl Example { pub(crate) fn fetch_all_local_and_remote( ctx: &Command::Context, - mut node: Option<&mut ProgressNode>, env_loader: &mut DotEnv::Loader, filesystem: &mut fs::FileSystem, ) -> crate::Result> { - let remote_examples = Example::fetch_all(ctx, env_loader, node.as_deref_mut())?; - if let Some(node_) = node { - node_.end(); - } + let remote_examples = Example::fetch_all(ctx, env_loader)?; let mut examples: Vec = remote_examples.into_vec(); { @@ -2155,7 +2114,6 @@ impl Example { pub(crate) fn fetch_all( ctx: &Command::Context, env_loader: &mut DotEnv::Loader, - progress_node: Option<&mut ProgressNode>, ) -> crate::Result> { let url = URL::parse(Self::EXAMPLES_URL); let http_proxy = env_loader.get_http_proxy_for(&url); @@ -2174,10 +2132,6 @@ impl Example { )); async_http.client.flags.reject_unauthorized = env_loader.get_tls_reject_unauthorized(); - if Output::enable_ansi_colors_stdout() { - async_http.client.progress_node = progress_node.map(core::ptr::NonNull::from); - } - let response = match async_http.send_sync(mutable) { Ok(r) => r, Err(err) => { @@ -2291,60 +2245,6 @@ impl Example { } } -struct CreateListExamplesCommand; - -impl CreateListExamplesCommand { - fn exec(ctx: &Command::Context) -> crate::Result<()> { - let filesystem = fs::FileSystem::init(None)?; - let mut env_loader = DotEnv::Loader::init(); - - env_loader.load_process()?; - - let mut progress = Progress { - supports_ansi_escape_codes: Output::enable_ansi_colors_stderr(), - ..Default::default() - }; - // `Progress::start` returns `&mut Node` borrowing `progress`; detach - // via raw pointer so `progress.refresh()` can re-borrow below. - let node: *mut ProgressNode = progress.start(b"Fetching manifest", 0); - progress.refresh(); - - // SAFETY: FileSystem::init returns the process-global singleton; valid for 'static. - let filesystem = unsafe { &mut *filesystem }; - // SAFETY: `node` points into `progress`, which outlives this call; single-threaded. - let examples = Example::fetch_all_local_and_remote( - ctx, - Some(unsafe { &mut *node }), - &mut env_loader, - filesystem, - )?; - bun_core::prettyln!( - "Welcome to bun! Create a new project by pasting any of the following:\n", - ); - Output::flush(); - - Example::print(&examples, None); - - bun_core::prettyln!( - "# You can also paste a GitHub repository:\n\n bun create ahfarmer/calculator calc\n", - ); - - if let Some(homedir) = env_loader.map.get(bun_core::env_var::HOME.key()) { - bun_core::prettyln!( - "This command is completely optional. To add a new local template, create a folder in {}/.bun-create/. To publish a new template, git clone https://github.com/oven-sh/bun, add a new folder to the \"examples\" folder, and submit a PR.", - bstr::BStr::new(homedir), - ); - } else { - bun_core::prettyln!( - "This command is completely optional. To add a new local template, create a folder in $HOME/.bun-create/. To publish a new template, git clone https://github.com/oven-sh/bun, add a new folder to the \"examples\" folder, and submit a PR.", - ); - } - - Output::flush(); - Ok(()) - } -} - struct GitHandler; static SUCCESS: AtomicU32 = AtomicU32::new(0); diff --git a/src/runtime/cli/init_command.rs b/src/runtime/cli/init_command.rs index 8b23c6274da9..9823c0eb44a5 100644 --- a/src/runtime/cli/init_command.rs +++ b/src/runtime/cli/init_command.rs @@ -681,18 +681,8 @@ impl InitCommand { let need_run_bun_install; { - let all_dependencies = template.dependencies(); - let dependencies = all_dependencies.dependencies; - let dev_dependencies = all_dependencies.dev_dependencies; - let mut needed_dependencies = IntegerBitSet::<64>::init_empty(); + let dev_dependencies = DEV_DEPENDENCIES; let mut needed_dev_dependencies = IntegerBitSet::<64>::init_empty(); - needed_dependencies.set_range_value( - bun_collections::bit_set::Range { - start: 0, - end: dependencies.len(), - }, - true, - ); needed_dev_dependencies.set_range_value( bun_collections::bit_set::Range { start: 0, @@ -701,17 +691,6 @@ impl InitCommand { true, ); - let needs_dependencies = 'brk: { - if let Some(deps) = object.get(b"dependencies") { - for (i, dep) in dependencies.iter().enumerate() { - if deps.get(dep.name).is_some() { - needed_dependencies.unset(i); - } - } - } - break 'brk needed_dependencies.count() > 0; - }; - let needs_dev_dependencies = 'brk: { if let Some(deps) = object.get(b"devDependencies") { for (i, dep) in dev_dependencies.iter().enumerate() { @@ -738,22 +717,7 @@ impl InitCommand { true }; - need_run_bun_install = - needs_dependencies || needs_dev_dependencies || needs_typescript_dependency; - - if needs_dependencies { - let mut dependencies_object = dependency_map(object, b"dependencies"); - let mut iter = needed_dependencies.iter_set(); - while let Some(index) = iter.next() { - let dep = &dependencies[index]; - dependencies_object.data.as_e_object_mut().put_string( - &bump, - dep.name, - dep.version, - )?; - } - object.put(&bump, b"dependencies", dependencies_object)?; - } + need_run_bun_install = needs_dev_dependencies || needs_typescript_dependency; if needs_dev_dependencies { let mut obj = dependency_map(object, b"devDependencies"); @@ -777,10 +741,6 @@ impl InitCommand { } } - if template.is_react() { - template.write_to_package_json(&mut fields, &bump)?; - } - 'write_package_json: { let (fd, created_close): (Fd, Option) = match package_json_file .as_ref() @@ -1165,7 +1125,7 @@ impl RadioChoice for ReactTemplateChoice { } // ────────────────────────────────────────────────────────────────────────── -// DependencyNeeded / DependencyGroup +// DependencyNeeded // ────────────────────────────────────────────────────────────────────────── #[derive(Copy, Clone)] @@ -1174,155 +1134,10 @@ pub(crate) struct DependencyNeeded { pub version: &'static [u8], } -struct DependencyGroup { - pub dependencies: &'static [DependencyNeeded], - pub dev_dependencies: &'static [DependencyNeeded], -} - -impl DependencyGroup { - const BLANK: DependencyGroup = DependencyGroup { - dependencies: &[], - dev_dependencies: &[DependencyNeeded { - name: b"@types/bun", - version: b"latest", - }], - }; - - // `const` cannot concat slices; the lists are hand-expanded below. - const REACT: DependencyGroup = DependencyGroup { - dependencies: &[ - DependencyNeeded { - name: b"react", - version: b"^19", - }, - DependencyNeeded { - name: b"react-dom", - version: b"^19", - }, - ], - dev_dependencies: &[ - DependencyNeeded { - name: b"@types/react", - version: b"^19", - }, - DependencyNeeded { - name: b"@types/react-dom", - version: b"^19", - }, - // ++ blank.devDependencies - DependencyNeeded { - name: b"@types/bun", - version: b"latest", - }, - ], - }; - - const TAILWIND: DependencyGroup = DependencyGroup { - dependencies: &[ - DependencyNeeded { - name: b"tailwindcss", - version: b"^4", - }, - // ++ react.dependencies - DependencyNeeded { - name: b"react", - version: b"^19", - }, - DependencyNeeded { - name: b"react-dom", - version: b"^19", - }, - ], - dev_dependencies: &[ - DependencyNeeded { - name: b"bun-plugin-tailwind", - version: b"latest", - }, - // ++ react.devDependencies - DependencyNeeded { - name: b"@types/react", - version: b"^19", - }, - DependencyNeeded { - name: b"@types/react-dom", - version: b"^19", - }, - DependencyNeeded { - name: b"@types/bun", - version: b"latest", - }, - ], - }; - - const SHADCN: DependencyGroup = DependencyGroup { - dependencies: &[ - DependencyNeeded { - name: b"class-variance-authority", - version: b"latest", - }, - DependencyNeeded { - name: b"clsx", - version: b"latest", - }, - DependencyNeeded { - name: b"tailwind-merge", - version: b"latest", - }, - DependencyNeeded { - name: b"tw-animate-css", - version: b"latest", - }, - DependencyNeeded { - name: b"lucide-react", - version: b"^1", - }, - DependencyNeeded { - name: b"@radix-ui/react-label", - version: b"latest", - }, - DependencyNeeded { - name: b"@radix-ui/react-select", - version: b"latest", - }, - DependencyNeeded { - name: b"@radix-ui/react-slot", - version: b"latest", - }, - // ++ tailwind.dependencies - DependencyNeeded { - name: b"tailwindcss", - version: b"^4", - }, - DependencyNeeded { - name: b"react", - version: b"^19", - }, - DependencyNeeded { - name: b"react-dom", - version: b"^19", - }, - ], - // ++ tailwind.devDependencies - dev_dependencies: &[ - DependencyNeeded { - name: b"bun-plugin-tailwind", - version: b"latest", - }, - DependencyNeeded { - name: b"@types/react", - version: b"^19", - }, - DependencyNeeded { - name: b"@types/react-dom", - version: b"^19", - }, - DependencyNeeded { - name: b"@types/bun", - version: b"latest", - }, - ], - }; -} +const DEV_DEPENDENCIES: &[DependencyNeeded] = &[DependencyNeeded { + name: b"@types/bun", + version: b"latest", +}]; // ────────────────────────────────────────────────────────────────────────── // Template @@ -1350,57 +1165,6 @@ impl TemplateFile { } impl Template { - fn is_react(self) -> bool { - matches!( - self, - Template::ReactBlank | Template::ReactTailwind | Template::ReactTailwindShadcn - ) - } - - fn write_to_package_json( - self, - fields: &mut PackageJSONFields, - bump: &bun_alloc::Arena, - ) -> Result<(), Error> { - type Rope = bun_ast::E::Rope; - fields.name = self.name().to_vec(); - // Allocate in the process-lifetime CLI arena. - let key: &mut Rope = crate::cli::cli_arena().alloc(Rope { - head: bun_ast::Expr::init(bun_ast::E::String::init(b"scripts"), bun_ast::Loc::EMPTY), - next: core::ptr::null_mut(), - }); - // SAFETY: object is arena-allocated and live for the command duration. - let object = unsafe { &mut *fields.object.unwrap().as_ptr() }; - let mut scripts_json = object.get_or_put_object(key, bump).map_err(|e| match e { - bun_ast::E::SetError::OutOfMemory => Error::Alloc(bun_alloc::AllocError), - bun_ast::E::SetError::Clobber => Error::Unexpected, - })?; - let the_scripts = self.scripts(); - let mut i: usize = 0; - while i < the_scripts.len() { - let script_name = the_scripts[i]; - let script_command = the_scripts[i + 1]; - - scripts_json.data.e_object_mut().unwrap().put_string( - bump, - script_name, - script_command, - )?; - i += 2; - } - Ok(()) - } - - fn dependencies(self) -> &'static DependencyGroup { - match self { - Template::Blank => &DependencyGroup::BLANK, - Template::ReactBlank => &DependencyGroup::REACT, - Template::ReactTailwind => &DependencyGroup::TAILWIND, - Template::ReactTailwindShadcn => &DependencyGroup::SHADCN, - Template::TypescriptLibrary => &DependencyGroup::BLANK, - } - } - fn name(self) -> &'static [u8] { match self { Template::Blank => b"bun-blank-template", @@ -1411,24 +1175,6 @@ impl Template { } } - fn scripts(self) -> &'static [&'static [u8]] { - match self { - Template::Blank | Template::TypescriptLibrary => &[], - Template::ReactTailwind | Template::ReactTailwindShadcn => &[ - b"dev", b"bun './**/*.html'", - b"build", b"bun 'REPLACE_ME_WITH_YOUR_APP_FILE_NAME.build.ts'", - ], - Template::ReactBlank => &[ - b"dev", - b"bun --hot .", - b"static", - b"bun build ./src/index.html --outdir=dist --sourcemap --target=browser --minify --define:process.env.NODE_ENV='\"production\"' --env='BUN_PUBLIC_*'", - b"build", - b"NODE_ENV=production bun .", - ], - } - } - const AGENT_RULE: &'static [u8] = include_bytes!("./init/rule.md"); const CURSOR_RULE: TemplateFile = TemplateFile::new( b".cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc", diff --git a/src/runtime/socket/Listener.rs b/src/runtime/socket/Listener.rs index 056788e3b556..c1ea2c557d1f 100644 --- a/src/runtime/socket/Listener.rs +++ b/src/runtime/socket/Listener.rs @@ -607,7 +607,6 @@ impl Listener { Ok(this_value) } - // `OWNED_PROTOS` stays unset: accepted sockets clone the listener's `protos`. fn accepted_socket_flags(&self) -> SocketFlags { let mut flags = SocketFlags::empty(); flags.set(SocketFlags::REJECT_UNAUTHORIZED, self.reject_unauthorized); @@ -1267,9 +1266,6 @@ impl Listener { // when sockets are reused for reconnection (common with MongoDB driver) prev.connection.set(Some(connection)); prev.local_binding.set(local_binding.clone()); - if prev.flags.get().contains(SocketFlags::OWNED_PROTOS) { - prev.protos.set(None); - } prev.protos .set(ssl_taken.as_mut().and_then(|s| s.take_protos())); prev.server_name @@ -1608,9 +1604,6 @@ fn connect_finish( // when sockets are reused for reconnection (common with MongoDB driver) prev.connection.set(Some(connection)); prev.local_binding.set(local_binding); - if prev.flags.get().contains(SocketFlags::OWNED_PROTOS) { - prev.protos.set(None); // drop old Box - } prev.protos.set(ssl.as_mut().and_then(|s| s.take_protos())); prev.server_name .set(ssl.as_mut().and_then(|s| s.take_server_name())); diff --git a/src/runtime/socket/socket_body.rs b/src/runtime/socket/socket_body.rs index a04301c8d3f1..53efab93f277 100644 --- a/src/runtime/socket/socket_body.rs +++ b/src/runtime/socket/socket_body.rs @@ -3745,7 +3745,7 @@ impl NewSocket { // releases `raw_handlers`. No poll_ref — `tls` keeps the loop // alive. active_connections=1 was already on raw_handlers from // `this`. - flags: Cell::new(Flags::BYPASS_TLS | Flags::IS_ACTIVE | Flags::OWNED_PROTOS), + flags: Cell::new(Flags::BYPASS_TLS | Flags::IS_ACTIVE), this_value: JsCell::new(JsRef::empty()), poll_ref: JsCell::new(KeepAlive::init()), ref_pollref_on_connect: Cell::new(true), @@ -4175,7 +4175,7 @@ pub(crate) struct StoredVerifyError { // ────────────────────────────────────────────────────────────────────────── bitflags::bitflags! { - #[derive(Clone, Copy, PartialEq, Eq)] + #[derive(Clone, Copy, PartialEq, Eq, Default)] pub struct Flags: u16 { const IS_ACTIVE = 1 << 0; /// Prevent onClose from calling into JavaScript while we are finalizing @@ -4184,7 +4184,6 @@ bitflags::bitflags! { const HANDSHAKE_COMPLETE = 1 << 3; const EMPTY_PACKET_PENDING = 1 << 4; const END_AFTER_FLUSH = 1 << 5; - const OWNED_PROTOS = 1 << 6; const IS_PAUSED = 1 << 7; const ALLOW_HALF_OPEN = 1 << 8; /// Set on the `raw` half of an `upgradeTLS` pair. Writes route through @@ -4248,13 +4247,6 @@ fn server_ctx_requests_cert(ctx: Option<*mut SSL_CTX>) -> bool { unsafe { boringssl_sys::SSL_CTX_get_verify_mode(ctx) & boringssl_sys::SSL_VERIFY_PEER != 0 } } -impl Default for Flags { - fn default() -> Self { - // Default: `owned_protos` true, all others false. - Flags::OWNED_PROTOS - } -} - // ────────────────────────────────────────────────────────────────────────── // SocketMode // ────────────────────────────────────────────────────────────────────────── diff --git a/src/sql_jsc/postgres/PostgresSQLConnection.rs b/src/sql_jsc/postgres/PostgresSQLConnection.rs index 39624b865b0d..d7bda2fa50f0 100644 --- a/src/sql_jsc/postgres/PostgresSQLConnection.rs +++ b/src/sql_jsc/postgres/PostgresSQLConnection.rs @@ -12,7 +12,7 @@ use crate::jsc::{ }; use bun_boringssl as BoringSSL; use bun_boringssl_sys::OwnedSslCtx; -use bun_collections::{OffsetByteList, StringHashMap, StringMap}; +use bun_collections::{OffsetByteList, StringHashMap}; use bun_core::strings; use bun_core::{self}; use bun_io::KeepAlive; @@ -136,8 +136,6 @@ pub struct PostgresSQLConnection { // the conservative GC scan covers stack/registers only. pub(crate) js_value: JsCell, - pub(crate) backend_parameters: JsCell, - // Self-referential — `database`/`user`/`password`/`path`/`options` are slices // into `options_buf` (built via StringBuilder in `call`). Struct is Box-allocated // and never moves (intrusive refcount), so the `RawSlice` backing-outlives-holder @@ -1198,7 +1196,6 @@ pub(crate) fn call(global_object: &JSGlobalObject, callframe: &CallFrame) -> JsR prepared_statement_id: Cell::new(0), pending_activity_count: AtomicU32::new(0), js_value: JsCell::new(crate::jsc::JsRef::empty()), - backend_parameters: JsCell::new(StringMap::init(true)), database, user: username, password, @@ -2471,17 +2468,8 @@ impl PostgresSQLConnection { let _ = protocol::CopyData::decode_internal(reader.reborrow())?; } MessageType::ParameterStatus => { - let parameter_status = - protocol::ParameterStatus::decode_internal(reader.reborrow())?; - self.backend_parameters - .with_mut(|m| { - m.insert( - parameter_status.name.slice(), - parameter_status.value.slice(), - ) - }) - .map_err(|_| AnyPostgresError::OutOfMemory)?; - // parameter_status dropped at scope end + // Decode to consume the message from the stream; the payload is unused. + let _ = protocol::ParameterStatus::decode_internal(reader.reborrow())?; } MessageType::ReadyForQuery => { let _ready_for_query = protocol::ReadyForQuery::decode_internal(reader.reborrow())?;