{"slug": "bun-v1-3-1", "title": "Bun v1.3.1", "summary": "Bun v1.3.1 introduces significant performance improvements, including up to 2x faster builds for projects using isolated linkers or symlinks, and faster installs by removing an unnecessary sleep() call when no peer dependencies are present. The update also adds new testing features like a global `vi` object for Vitest compatibility, `--pass-with-no-tests` and `--only-failures` flags, and enhanced sourcemap support for legal comments. Additionally, the package manager now supports the `:email` field in `.npmrc` for private registries and introduces selective hoisting via `publicHoistPattern` and `hoistPattern` configurations.", "body_md": "To install Bun\ncurl -fsSL https://bun.sh/install | bash\nnpm install -g bun\npowershell -c \"irm bun.sh/install.ps1|iex\"\nscoop install bun\nbrew tap oven-sh/bun\nbrew install bun\ndocker pull oven/bun\ndocker run --rm --init --ulimit memlock=-1:-1 oven/bun\nTo upgrade Bun\nbun upgrade\nFaster bun build\nFor projects that use --linker=isolated\n, pnpm\n, or otherwise use lots of symlinks, bun build\ngets up to 2x faster.\nIn the next version of Bun\n— Jarred Sumner (@jarredsumner) October 12, 2025\nbun build with sourcemaps & minification enabled gets 2x faster pic.twitter.com/bjaU6YK9xV\nSourcemaps for legal comments in bun build\nSource maps now include entries for preserved multi-line comments (including CRLF line endings), ensuring legal comments in bundled output map back to their original sources for accurate debugging and tooling.\nimport.meta\nin CommonJS\nbun build --format=cjs\nwill now inline some usages of import.meta\nsimilarly to existing behavior with __dirname\nand __filename\n. This prevents syntax errors that could occur when transpiling files using import.meta\nto CommonJS, such as packages like @sentry/node\n.\nNew in bun test\nvi\nglobal\nbun test\nnow exposes Vitest's global vi\n(including types). vi\nis defined in test files by default, enabling vi.fn\n, vi.mock\n, vi.spyOn\n, and related APIs without imports.\ntest(\"hello\", () => {\nconst fn = vi.fn();\nexpect(fn).not.toHaveBeenCalled();\nfn();\nexpect(fn).toHaveBeenCalled();\n});\nThis makes it a little bit easier to migrate from Vitest to bun test\n.\nbun test --pass-with-no-tests\nThe test runner now supports --pass-with-no-tests\n, which exits with code 0 when no tests are found or when active filters match no tests. This mirrors Jest and Vitest behavior and is useful in monorepos where some packages may not contain tests. Without the flag, bun test\ncontinues to exit with 1 when no tests are found. Actual test failures still exit non-zero.\nbun test --pass-with-no-tests\nbun test v1.3.1\nNo tests found!\nTests need \".test\", \"_test_\", \".spec\" or \"_spec_\" in the filename (ex: \"MyApp.test.ts\")\nLearn more about bun test: https://bun.com/docs/cli/test\necho $?\n0\nThanks to @pfg for the contribution!\nbun test --only-failures\nA new --only-failures\nflag (and test.onlyFailures\noption in bunfig.toml\n) hides passing tests and prints only failures, making large suites and CI logs easier to scan. The final summary (pass/skip/fail, totals) is still printed.\nbun test --only-failures\nbun test v1.3.1\n10 pass\n0 fail\nRan 1 tests across 1 file. [8.00ms]\nThanks to @pfg for the contribution\nNew in bun install\nFaster installs when no peerDependencies\nare present\nWe removed a sleep()\nin Bun’s package manager! It waited for peer dependencies to install, even if there were no peer dependencies to install.\nThanks to @dylan-conway for fixing this!\n:email\nin .npmrc\nSome private registries (e.g., Sonatype Nexus) require an email alongside username/password or token. bun install now reads and forwards the :email\nfield from .npmrc\nfor both default and scoped registries, enabling successful authentication in these setups.\n# .npmrc\n//registry.example.com/:email=user@example.com\n//registry.example.com/:username=myuser\n//registry.example.com/:_password=base64encodedpassword\n# or with a token\n//registry.example.com/:_authToken=xxxxxx\nThanks to @dylan-conway for the contribution!\npublicHoistPattern\nand hoistPattern\nBun now supports selective hoisting when using the isolated linker.\npublicHoistPattern\ninbunfig.toml\n(andpublic-hoist-pattern\nin.npmrc\n) hoists matching transitive dependencies to the root node_modules so tools like ESLint and TypeScript lib augmentations can be discovered across a workspace.hoistPattern\ncontrols what gets hoisted into node_modules/.bun/node_modules.\nThis makes it possible to explicitly opt-in packages such as @types/*\n, eslint\nplugins, or better-typescript-lib\nfor global visibility in monorepos without reverting to full hoisting.\n[install]\n# String form\npublicHoistPattern = \"@types*\"\n# Array form\npublicHoistPattern = [ \"@types*\", \"*eslint*\" ]\n# Control internal hoisting into node_modules/.bun/node_modules\nhoistPattern = [ \"@types*\", \"*eslint*\" ]\n# Equivalent to bunfig.toml, useful when sharing config across tools\npublic-hoist-pattern[]=@typescript/*\npublic-hoist-pattern[]=*eslint*\nFileHandle.readLines()\nin node:fs/promises\nBun now implements Node.js’s FileHandle.readLines()\n, enabling efficient, backpressure-aware async iteration over file lines using for-await-of. This handles empty lines and CRLF correctly and accepts the same options as createReadStream\n(e.g., encoding).\nimport { open } from \"node:fs/promises\";\nconst file = await open(\"file.txt\");\ntry {\nfor await (const line of file.readLines({ encoding: \"utf8\" })) {\nconsole.log(line);\n}\n} finally {\nawait file.close();\n}\nThanks to @nektro for the contribution!\nBundler & Transpiler bugfixes\n- Improved: Bundler CJS output incorrectly respected\n__esModule\nwhen the importer used ESM syntax.__toESM\nnow basesisNodeMode\non the importing module's syntax (ESM import/export setsisNodeMode=1\n), matching - Improved:\nbun build --no-bundle\nnow rejects HTML entrypoints with a clear error (\"HTML imports are only supported when bundling\") - Fixed: An assertion failure when transpiling code that evaluates string equality in constant-known expressions involving concatenated strings (rope strings) in rare cases.\n- Fixed:\nBun.build()\nwithcompile: true\nfailed to apply sourcemaps (includingsourcemap: \"inline\" or true\n), causing stack traces to reference virtual bundled paths (/$bunfs/root/) instead of original files/lines. The API now mirrorsbun build --compile\nby emitting external sourcemaps in compile mode, restoring correct file names and line numbers in error stacks. - Fixed:\nbun build --bytecode\ncould fail when code referencedimport.meta.url\norimport.meta.dir\n. These now compile without errors. - Fixed: An assertion failure in\nbun build --production\nimpacting Windows whenreact-jsxdev\nis present in tsconfig.json - Fixed: Incorrect memory management for error message strings in\nbun build --compile\nfor single-file executables in certain cases. - Fixed: Assertion failure when encountering certain invalid async function syntax patterns. Now Bun reports an error.\n- Fixed: \"Scope mismatch while visiting\" panic when encountering TypeScript enums with function-valued members (e.g.\nA = () => {}\n) - Fixed: A race condition when using\nwith {type: \"macro\"}\nwhen executed simultaneously for the first time across multiple threads inbun build\nbun test bugfixes\n- Fixed:\nbun test\ncould crash when formatting errors for extremely deeply nested objects\nbun install / bun pm\n- Fixed:\nbun install\nwith--linker=isolated\non macOS could fail withEXDEV\n(Cross-device link) when the project lived on a non-system APFS volume or across volumes (common in workspaces/monorepos). Installs now handle cross-volume linking correctly and complete reliably. - Fixed:\nbun install\nwith the isolated linker did not create symlinks for self-referencing workspace dependencies in monorepos (e.g.,\"workspace:\\*\"\nor\"workspace:.\"\n), preventing packages from resolving their own exports vianode_modules\n. These self-deps are now correctly linked. - Fixed: A determinism bug when constructing\nnode_modules/.bun/node_modules\nunder--linker=isolated\n, which could cause different versions to be hoisted across installs and enable unintended \"phantom\" dependencies across workspaces despite using--linker=isolated\n. - Fixed: Missing error handling when iterating directory entries in certain cases.\n- Fixed:\nbun pm pack\nnow always includes files and directories declared via\"bin\"\nand\"directories.bin\"\neven when they are not listed in\"files\"\n, matching npm pack behavior. This prevents missing CLI binaries in published tarballs and deduplicates paths when they appear in both\"bin\"\n/\"directories.bin\"\nand\"files\"\nbunx\n- Fixed: A panic in\nbunx\non Windows that could occur when npm package names contained multi-byte/non-ASCII characters (which npm's registry does not support).\nBun.SQL / MySQL\n- Fixed: Missing error handling in MySQL parameter binding when passing boxed primitives (\nnew Number(...)\n,new Boolean(...)\n) or other non-indexable values. Bun now throws a descriptive error instructing you to use primitive numbers/booleans instead. - Fixed: MySQL TLS connections could spin a CPU core at 100% after a query (sslmode=require/prefer), especially on macOS. Timers are now initialized only after connection status transitions complete, preventing runaway timeouts.\n- Fixed: a regression from v1.2.23 causing idle MySQL connections to keep the event loop alive. Processes now exit cleanly after queries instead of hanging\nBun.RedisClient\n- Fixed:\nBun.RedisClient\nnow validates connection URLs and throws on invalid parameters (e.g., out-of-range ports) instead of silently defaulting to localhost:6379\nBun.S3Client\n- Fixed: Memory leak in\nBun.S3Client\nlistObjects\nresponse parsing (ETag handling) that could cause unbounded memory growth when listing large buckets or repeatedly callinglistObjects\nbun:ffi\n- Fixed:\nbun:ffi\nnow surfaces actionabledlopen\n(linking) errors. When a library cannot be opened, the error includes the library path and the OS error (e.g. \"invalid ELF header\", \"No such file or directory\") instead of a generic message. - Fixed:\nlinkSymbols()\nandCFunction()\nnow throw a clear error when a symbol definition is missing aptr\nfield, and an error propagation issue inlinkSymbols()\nwas corrected so errors are thrown consistently.\nBun Shell ($)\n- Fixed: a memory leak in Bun Shell command-line arguments.\n- Fixed: a crash that could occur when Bun Shell is garbage collected.\n- Fixed: Blocking I/O on macOS when writing large (>1 MB) outputs to pipes\n- Fixed: Potential assertion failure on Windows when spawning from long paths or when 8.3 short names are disabled.\n- Fixed: Missing error handling when monitoring shell writers on Windows\nWebSocket client & server\n- Fixed: WebSocket upgrades ignored cookies set with\nreq.cookies.set()\nprior toserver.upgrade()\n; theSet-Cookie\nheader is now included in the 101 Switching Protocols response, with or without custom headers - Fixed: Incorrect handling of WebSocket client close frames could panic when the close frame payload was fragmented across multiple TCP packets. Bun now buffers fragmented close frames and processes them only when complete\nNode.js Compatibility\n- Fixed: a crash that could occur when terminating a Worker that used N-API. This impacted\nnext build\nwith Turbopack enabled. - Fixed: Missing libuv error codes\nUV_ENOEXEC\nandUV_EFTYPE\nare now recognized on Windows. - Fixed: The\nnode:buffer\nESM export ofINSPECT_MAX_BYTES\nwas incorrectly exposed as an accessor. It is now a plain number, matching Node.js semantics; reassigningbuffer.INSPECT_MAX_BYTES\ndoes not affect the ESM named import. - Fixed:\nResponse.json()\nnow throws a Node.js-compatibleTypeError\n(\"Value is not JSON serializable\") for non-serializable top-level values (Symbol\n,Function\n,undefined\n).BigInt\nnow throws \"Do not know how to serialize a BigInt\".\nThank you to Martin Schwarzl of Cloudflare for reporting these bugs:\n- Fixed: out-of-bounds write in\nBuffer.prototype.writeBigInt64{LE,BE}\nandBuffer.prototype.writeBigUInt64{LE,BE}\n- Fixed: assertion failure when setting\nprocess.title\nwith UTF‑16 characters - Fixed: missing exception handling for a\nReadableStream\nfor use by aResponse.prototype.body\nthat throws during initialization\nWeb APIs\n- Fixed: a bug that could cause excessive memory growth in certain rare cases when consuming\nfetch()\nresponse bodies chunk-by-chunk.\nThank you to Martin Schwarzl of Cloudflare for also reporting the following bugs:\n- Fixed: URL heap size accounting could overflow, causing pathological GC behavior when handling large URLs. Memory usage is now reported accurately.\n- Fixed: assertion failure in\nURLSearchParams.prototype.toJSON()\ninvolving numeric string keys - Fixed: assertion failure in\nHeaders.prototype.append()\ninvolving numeric header names\nYAML\n- Fixed:\nBun.YAM", "url": "https://wpnews.pro/news/bun-v1-3-1", "canonical_source": "https://bun.com/blog/bun-v1.3.1", "published_at": "2025-10-22 10:11:00+00:00", "updated_at": "2026-05-22 20:44:05.016386+00:00", "lang": "en", "topics": ["developer-tools", "open-source", "products"], "entities": ["Bun", "Jarred Sumner", "Vitest", "pnpm", "@sentry/node"], "alternates": {"html": "https://wpnews.pro/news/bun-v1-3-1", "markdown": "https://wpnews.pro/news/bun-v1-3-1.md", "text": "https://wpnews.pro/news/bun-v1-3-1.txt", "jsonld": "https://wpnews.pro/news/bun-v1-3-1.jsonld"}}