@Electroid this causes the tests to never cancel. GitHub has a concurrent actions limit which we easily reach. This causes CI to wait a long time before starting the job, wasting our time.
* node:http.request should emit events in the right order
* Apply formatting changes
* remove runOnNextTick alias
* make private event a symbol
* clean test
* fix regressions and add more tests
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred-Sumner <Jarred-Sumner@users.noreply.github.com>
* add: prevent script install to be spawned if bun install is invoked
* add: test for infinite install loop
* add: error message
* fix: error message, exit code, test
---------
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
* node:crypto: add blake2b512, sha512-224, sha3-*
* update submodule
* flesh out rest of api
* remove new bun.newCatchable
* add SHA512_224 to HashClasses
* remove SHA512_224 js class
* better allocation
* remove memcpy in path where buffer is provided to us
* add back benchmark
* move zig crypto things into specific struct
* Apply formatting changes
* centralize algorithm definitions into one spot
* rsa-256 was deleted
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred-Sumner <Jarred-Sumner@users.noreply.github.com>
* node:child_process: allow passing stdin,stdout,stderr to spawn
* this doesnt actually need to be limited to 0,1,2
* Apply formatting changes
* fix stream guards
* undo process internals change
* wrap check in function for better clarity
* lazy load node:fs more
---------
Co-authored-by: nektro <nektro@users.noreply.github.com>
* Make it work with abs patterns
* add tests
* fixes
* Make all the ported fast-glob tests work for absolute path patterns, fix some stuff
* fix scan test
* remove TestBuilder in scan.test.ts
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* think about the future
* waaaaaaaaaaa
* a
* testing
* make it faster
* fire
* macos and linux
* stuff
* a
* a
* CI
* buh
* disable in debug
* Apply formatting changes
* a
* a
* Apply formatting changes
* more review comment resolution
* a
* a
* oh no i started writing macos code from within windows i should stop and switch devices again
* rookie mistake
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: paperdave <paperdave@users.noreply.github.com>
* some work
* linux things
* linux things
* feat: tracestrings on Windows
* bwaa
* more work on the crash handler
* okay
* adgadsgbcxcv
* ya
* dsafds
* a
* wuh
* a
* bru h
* ok
* yay
* window
* alright
* oops
* yeah
* a
* a
* OOM handling
* fix on window
* Do not run tests outside test scope
* Fix tests
* Fix type errors and remove potentially precarious uses of unreachable
* yoops
* Remove all instances of "Ruh roh"
---------
Co-authored-by: Zack Radisic <56137411+zackradisic@users.noreply.github.com>
* packages wait for parent trees before install
* use `directoryExistsAt`
* missing increment
* fix faccessat
* swap destination and target
* update
* force
* only create destination dir before installing package
* fix windows symlink/junction
* increment, false on extracting
* done
* fix(which/windows): ignore file extension case
* feat(which): add test for `endsWithExtension` fun
* Revert "feat(which): add test for `endsWithExtension` fun"
This reverts commit fb3ad51de7.
* add test
---------
Co-authored-by: Georgijs <48869301+gvilums@users.noreply.github.com>
* fix path resolution for writeFile in nodefs
* add test
* [autofix.ci] apply automated fixes
* use force copy
* fix build
* fix test on windows
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* allow client renegotiation and allow server renegotiation with limits matching nodejs behavior
* wip before the refactoring and context separation
* investigate if BoringSSL can send a SSL_renegotiate request or only accept
* format-off
* option to disable server renegotiation
* allow tls options on https
* dead_socket when connectError
* propagate cert error
* test
* move the logic to the right place
* cleanup
* Update test/js/node/tls/renegotiation.test.ts
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Georgijs <48869301+gvilums@users.noreply.github.com>
* fix socket
* one more test
* always clean callback on deinit
* Update src/bun.js/api/bun/socket.zig
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* make context close private
* keep old logic
* move clean step to SocketContext.close
* add comment
* wait for close on stop
* cleanup
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* linter: allow a trailing field
* linter: dont fail if no matches are found
* lint: only import 'bun' once
* lint: ban std.mem.indexOfAny
* linter: ignore commented out code and ignore benchmarks
* this was testing nothing
* lint: ban std.debug.print
* this wasnt testing anything either
* Skeleton code for `bun run --workspace`
* Update run_command.zig
* implement directory traversal to find workspace root
* finish --workspace implementation
* clean up changes in run_command.zig
* add workspace tests, update harness to handle nested dirs
* [autofix.ci] apply automated fixes
* basic filtering
* [autofix.ci] apply automated fixes
* working filter without patterns
* update tests, filter mostly working
* simplify package name parsing, commit tests
* support filter even without workspace setup
* move filter arg handling to separate source file
* use bun.sys.chdir, match root package for scripts
* fix exit code handling
* ignore node_modules and directories starting with . in --filter
* progress converting --filter to use iterators
* convert filtering to use iterators
* cleanup
* implement DirEntry access method for glob (currently crashing)
* cleanup and fixes
* run js files in subprocess when filter flag passed
* clean up dead code
* fix fd leak in run_command.zig
* [autofix.ci] apply automated fixes
* fix issues after merge
* use posix-spawn in runBinary, fix resource PATH variable resource leak
* move filter argument to runtime category
* fix test harness
* add js and binary tests to filter-workspace
* [autofix.ci] apply automated fixes
* fix compile after merge
* [autofix.ci] apply automated fixes
* clean up filter-workspace test
* [autofix.ci] apply automated fixes
* fixes to running binaries
* fix actually setting cwd_override
* windows fixes
* address some review comments
* handle malformed JSON
* add various tests
* [autofix.ci] apply automated fixes
* update docs for filter
* [autofix.ci] apply automated fixes
* reset tinycc commit
* filtered run prototype
* make pretty
* implement abort handler (not working)
* make prettier
* prep for windows
* windows path and printing fixes
* implement log-style output (not tui)
* fix issues when logging to file
* revert a bunch of unecessary changes
* cleanup
* implement dependency order execution
* detect circular dependencies, fix cancel hang
* Fix `$PATH`
* ignore dep order on loop, stream on linux, sort pkgs
* support pre and post scripts
* add more filter tests, print elapsed time
* enable 'bun --filter' without run
* fix harness after merge
* [autofix.ci] apply automated fixes
* print number of scripts we're waiting for
* update docs, fix windows build
* fix tests on windows
* [autofix.ci] apply automated fixes
* fix uninitialized memory
* use terminal synchronized update sequences
* Add skip list
* Preallocate
* Use current bun in tests
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* add mention of .exists()
* show that the exists method returns a promise in the docs
* remove unnecessary white space
* update type ref to show that exists returns a promise
* windows: fs/promises: fix when writing to file opened in append mode
* add default values since we're using one now
* [autofix.ci] apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* fix: null is not an object at readableStreamCancel
* [autofix.ci] apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* [bundows] Make bun install 60% faster
* [autofix.ci] apply automated fixes
* Do not keep node_modules folder open between async tasks. Make sure we call runTasks on every event loop wakeup.
* Update install.zig
* Fix deadlock
* Make that deadlock impossible
* a little less repetitive
* Fix test failure with local tarball
* Get those tests to pass
* Normalize absolutely
* lets see how many times we call GetFinalPathNameByHandle
* Workaround https://github.com/ziglang/zig/issues/19586https://github.com/ziglang/zig/issues/19586
* Is the dev-server-100 test failure a hash table collision?
* Give it its own cache dir
* We cannot change the git task ids
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* If any failed to install, always exit with non-zero
* [autofix.ci] apply automated fixes
* This test should fail
* Update bun-link.test.ts
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* fix#9823
* subshell
* Refactor a bit and add a lot of tests
* delete random code
* make tests pass on windows
* Cleanup
* add sharp test
* Resolve comments
---------
Co-authored-by: Georgijs Vilums <georgijs.vilums@gmail.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* some fixes
* WIP
* wip wip
* more debug
* closer
* sending a really big payload at once is still broken
* now we need to avoid segfault happening inside onWritable after destroy
* opsie
* cleanup
* more cleanup
* more WIP, closer need to fix cork
* fix cork actually not writing non-optional data
* make onWritable return actually do something
* actually clean the on writable handler
* remove unreachable condition
* we are not looping anymore
* little revert
* fix possible fault
* inform backpressure on chunked encoding
* just queue when tryEnd
* remove unreachable code
* shell: organize imports
* shell: dont allocate when printing errors
* shell: implement $0, $1, argv accessors
* add more tests
* oops need this commit too
* make these logs listen to silencing logs
* expand switch else statements
* align behavior with bash
* this isnt referenced anywhere
* add missing test file
* add another test
* revert this change
* cache utf8 converted version of positionals
* rebase fixes
---------
Co-authored-by: Georgijs Vilums <georgijs.vilums@gmail.com>
* WIP: some fixes and improvements
* cleanup
* WIP: some fixes and improvements
* cleanup
* dont pause
---------
Co-authored-by: cirospaciari <ciro.spaciari@gmail.com>
* these comments were redundant
* better windows support here
* slightly better error message
* didnt realize this variable already existed
* fix node-gyp shim script
* move 'windows bin linking shim should work' to its own file
* run all lifecycle scripts on windows with bun shell
* tidy
* clean imports
* this seemed missing
* remove these comments
* fix the shim again
* fix posix release ensureTempNodeGypScript
* revert this change, it was correct before
* rename conditional -> binary
* Parse if clauses
* `if` works
* Conditional expressions
* Support If clause condition and branches multi-statements
* cond expr tests
* more
* Fix parse tests
* `&` commands
* clean up
* Make it compile for windows
* Fix test
* Remove If/Else/Elif/Then/Fi tokens
* Fix parsing ambiguities
* Resolve some comments
* More tests fix bugs
* Fix parsing and add more tests ported from GNU bash
* Fix `&`on left side of `&&` error message
* leak test fix hopefully
* todo some tests because `wait` is not implemented
* Disable background commands for now
* Resolve additional comments
* Fix merge conflicts
* Fix broken tests from merge
* Add `==` and `!=` and fix parsing bug
* wow
* fix 09401 test failing... forgot to update `this.inlined.len`
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* fix a few ipc issues
* a
* my own revisions
* remove none as a valid type
* a
* fix windows build
* remove comment
* make it work !!!!!!!!
* a
* formatter nonsense
* blah
* huge update refactor
* awa
* wow
* okay
* Revert "fix!: do not lookup cwd in which (#9691)"
This reverts commit 4869ebff24.
* fix which implementation to be more accurate
* t
* which tests windows
* [autofix.ci] apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* make the shell throw by default
* make shell default to throws(true)
* ok
* mv tests
* a
* a
* [autofix.ci] apply automated fixes
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* root scripts in foreground
* ignore if silent
* test for breaking changes
* move back to installPackages
* [autofix.ci] apply automated fixes
* boolean variable, comptime, 1_1_0
* flip the 1.1 flag
* add for the next batch of breakings
* make it buidl
* enable breaking changes tests
* fix version fmt
* silent node-gyp
* comment change
---------
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
* bun:test: implement test.todoIf and describe.todoIf
* fix bun-install-registry.test.ts and mark some as todo
* add even more tests
* remove todoIf from this file
* [autofix.ci] apply automated fixes
* fix regression
* this extra expect was incorrect
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* repro
* cleanup
* avoid shutdownRead on SSL
* still dont fix
* more
* some ssl
* cleanup
* handle shutdown
* make actually pass the tests
* fix STATUS_STACK_BUFFER_OVERRUN?
* revert some, cleanup fetch.tls.test
* make clear why we need on_handshake when closing
* more
* revert
* cleanup
* cleanup + less Bun.gc
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* setRawMode rewrite for Windows
* work on posix using old approach
* [autofix.ci] apply automated fixes
* no print
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* oooooh magic
* stuff
* run format
* ok
* yippee
* run the formatter back
* finish things up
* fix webkit
* more
* [autofix.ci] apply automated fixes
* fix compile
* fix compilation on windows, it seems to not work though :(
* update
* a
* v
* ok
* [autofix.ci] apply automated fixes
* OOPS
* bump bun to reduce ci bugs
* a
* js2native is done!
* improve array binding
* rebase
* some final stuff
* wasi fixes
* os
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* does this fix the windows build
* [autofix.ci] apply automated fixes
* a
* enable tar oop
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* add server ws.terminate
* [autofix.ci] apply automated fixes
* it has to be blazing fast
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* Fix undefined memory on subprocess exit immediately and fix crash when writing a lot of data
* format
* Test for #9458
* Document
* Lazily create iowriters (i think this solves fdleak tests?)
* Fix `big_data` test hanging
* I think this make leak tests more stable
* accidentally had deinit in another thread
* oops
* Fixes
* shell `big_data` test redirect to file
* stuff
* Fix windows /dev/null
* Increase timeout
* Resolve comments and better input test
* remove comment
* fix prompt test
* more time like leaky case
* remove comments
* fixed
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* WIP missing keepalive
* cleanup
* is a Bun.sleep bug?
* no bun sleep
* fix exception
* revert
* fix setTimeout/Bun.sleep
* add Bun.sleep keepalive test
* fixes
* one more bonus fix
* fix early firing of timers
* use localhost and pass the server.hostname
* opsie
* Fix undefined memory on subprocess exit immediately and fix crash when writing a lot of data
* format
* Test for #9458
* Document
* Lazily create iowriters (i think this solves fdleak tests?)
* Fix `big_data` test hanging
* I think this make leak tests more stable
* accidentally had deinit in another thread
* oops
* Fixes
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* fix napi tests
* only windows, update passing tests
* remove closing remainder
* fix child_process-node.test.js
* might fail in ci
* oops
* fix dns tests
* remove comment
* sometimes it is slow
* update test
* maybe fix timeout error
* one more try
* off by one, valid npm package name
* update test
* fix hot tests
* revert
* remove close
* Fix regression with console.log in --watch on linux
* Unset CLOEXEC
* more
* Enable inheritance on windows
* Don't forget to close the handles...
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* Enable more C++ warnings
* Only enable these ones in release builds
* Update MessagePortChannel.cpp
* Update BunProcess.cpp
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* Fix bundling not using ascii_only
* add utf8 test to bundler_compile & make test source ascii
* [autofix.ci] apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* run-eval.test.ts
* transpiler-cache.test.ts
* node net
* some open things
* a
* a
* yikes
* incredible
* run it back
* a
* this code is what i like to call, incorrect
* ok its all worng
* remove an assertion that is wrong again
* update test things and rebase
* performance test
* mark filesink with mkfifo as todo. see #8166
* hehe
* not done
* awa
* fs test pass
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* Replace some of std.ChildProcess with bun.spawnSync
* Update process.zig
* Fix some build errors
* Fix linux build
* Keep error
* Don't print a mesasge in this case
* Update spawn.test.ts
* Make `bun install` faster on Linux
* Comments + edgecases
* Fix the tests
* Add bun install launch.json
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Zack Radisic <zack@theradisic.com>
* more tests
* update migration.zig
* fix up paths
* update tests
* update tests
* test
* test
* update registry tests
* comments
* early exit if stream is invalid
* dont pass invalid_fd to openFileAtWindows
* fix merge
* misc crash fix
* make this use optional pointers instead of 0xaa
* ensure absolute paths are propagated properly
* package.json expects forward slash
* this assert was invalid
* add panic checks
* pass bun-remove
* more panic checks
* test: pass bun-add
* querying these hangs outside bun too
* fix compile error from merge conflict resolution
* use compileError instead of comptime unreachable
* tidy
* bunx: check for the .exe bin extension
* bunx: another route to make cache path if it doesnt exist
* install: another case of FolderResolution.getOrPut expecting absolute path
* fix a bun install crash
* dont print zig stack trace if bun install fails
* test: pass bun-link
* test: bunx: add more expects
* test: bun-install-registry: pass
* test: bun-install: pass
* test: bun-pm: pass
* fix merge main error
* fix posix tests
* fix last failing test in bun-install.test.ts
symlink difference between platforms
* bun-install-registry.test.ts fix
* bun-run.test.ts: remove stray console log
---------
Co-authored-by: Meghan Denny <meghan@bun.sh>
Co-authored-by: Meghan Denny <hello@nektro.net>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* make sure source data is set too
* make default trusted dependencies work
* undo
* test
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* Make some things sync on windows
* WIP
* WIP
* remove uses to uv_default_loop
* remove a compiler warning on windows
* edfghjk
* Windows build fixes
* Fixup
* bundows
* Add quotes
* Fix --cwd arg on Windows
* comment
* move this up
* Fix some tests
* `mv` tests pass
* spawn.test passes again
* Allow .sh file extension for Windows
* Unmark failing tests
* env test pass
* windows
* Fix some tests
* Update ProcessBindingTTYWrap.cpp
* Update CMakeLists.txt
* Set tmpdir
* Make it 5s on windows
* Fixup
* Fixup
* Update ProcessBindingTTYWrap.cpp
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
* Fix crypto module to have proper id values for sign function
* Revert adding id hash to DSA sign functions - DSA algorithm doesnt use it
* Add tests for crypto.createSign() and crypto.verifySign()
* [autofix.ci] apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* Add openSUSE Tumbleweed to the list of supported Linux distributions in CMakeLists.txt
* openSUSE Tumbleweed setup
* Revert "Add openSUSE Tumbleweed to the list of supported Linux distributions in CMakeLists.txt"
This reverts commit 93faed88a1.
---------
Co-authored-by: nellfs <nellfs@localhost.localdomain>
* fix ReadFile and fix isEligible for sendfile on windows
* give it a little more time
* actually test tls property
* Update src/bun.js/webcore/blob/ReadFile.zig
Co-authored-by: John-David Dalton <john.david.dalton@gmail.com>
* getServers test on windows
* retry
* check comptime first on isEligible
* wip body-stream
* oopsie
* opsie 2
* revert this
* test
---------
Co-authored-by: John-David Dalton <john.david.dalton@gmail.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* Use system shell + add to bunfig
* Update CMakeLists.txt
* Fix tests + flags
* Use execPath
* windows
* Propagate exit code
* Add test for default shell in use
* Update bun-run-bunfig.test.ts
* Update bun-run-bunfig.test.ts
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* wip
* Fix a bunch of stuff
* Fix cat
* Fix shell rm windows
* Fix glob scan test on windows
* Fix rm on windows
* stuff
* make it compile on windows
* [autofix.ci] apply automated fixes
* fix compile
* Wow
* Minor changes
* Ensure handle is closed
* Regular files are not pollable on linux
* dupe the blob son
* fix mem leak stuf
* dont use O_NONBLOCK
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* Upgrade HTTPParser.h from uWS v20.6.0 to v20.62.0
* Make MAX_FALLBACK_SIZE larger to allow for large redirect urls
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* fix recursion
* accurate count of blocked package scripts
* update
* fix merge
* reset pipereaders, set bin linker error correctly
* more pretty
* small changes
* e
* update tests
* this one too
* bun.start_time, iterate package_ids, remove put
* WIP sync close (shows ref count bug in stream)
* fix closing on PipeWriter and PipeReader
* remove old todos
* join
* Some shell changes
at least it compiles
* fix some compile errors
* fix ref/unref server on windows
* actually use the ref count in this places
* make windows compile again
* more tests passing
* Make shell compile again
* Slowly remove some `@panic("TODO SHELL")`
* Eliminate `@panic("TODO SHELL")` for BufferedWriter
* Holy cleansing of `@panic("TODO SHELL")`
at least it compiles now
* Okay now the shell compiles, but segfaults
* Fix compiler errors
* more stable stream and now Content-Range pass
* make windows compile again
* revert stuff until the fix is actually ready
* revert onDone thing
* Fix buffered writer for shell
* Fix buffered writer + shell/subproc.zig and windows build
* Fix for #8982 got lost in the merge
* Actually buffer subproc output
* Fix some stuff shell
* oops
* fix context deinit
* fix renderMissing
* shell: Fix array buffer
* more stable streams (#9053)
fix stream ref counting
* wip
* Remove `@panic("TODO")` on shell event loop tasks and Redirect open flags got lost in merge
* Support redirects
* fixes
cc @cirospaciari
* Update ReadableStreamInternals.ts
* Fix spurious error
* Update stream.js
* leak
* Fix UAF
cc @cirospaciari
* Fix memory leaks
* HOLY FUCK big refactor
* misc cleanup
* shell: Fix a bunch of tests
* clean up
* gitignore: fix ending newline
* get windows compiling again
* tidy
* hide linker warn with icu
* closeIfPossible
* Better leak test
* Fix forgetting to decrement reference count
* Update stdio.zig
* Fix shell windows build
* Stupid unreachable
* Woops
* basic echo hi works on windows
* Fix flaky test on Windows
* Fix windows regression in Bun.main (#9156)
* Fix windows regression in Bun.main
* Handle invalid handles
* Fix flaky test
* Better launch config
* Fixup
* Make this test less flaky on Windows
* Fixup
* Cygwin
* Support signal codes in subprocess.kill(), resolve file path
* Treat null as ignore
* Ignore carriage returns
* Fixup
* shell: Fix IOWriter bug
* shell: Use custom `open()`/`openat()`
* windows shell subproc works
* zack commit
* I think I understand WindowsStreamingWriter
* fix thing
* why were we doing this in tests
* shell: Fix rm
* shell: Add rm -rf node_modules/ test
* shell: use `.runAsTest()` in some places to make it easier to determine which test failed
* [autofix.ci] apply automated fixes
* woopsie
* Various changes
* Fix
* shell: abstract output task logic
* shell: mkdir builtin
* fixup
* stuff
* shell: Make writing length of 0 in IOWriter immediately resolve
* shell: Implement `touch`
* shell: basic `cat` working
* Make it compile on windows
* shell: Fix IOReader bug
* [autofix.ci] apply automated fixes
* fix windows kill on subprocess/process
* fix dns tests to match behavior on windows (same as nodejs)
* fix windows ci
* again
* move `close_handle` to flags in `PipeWriter` and fix shell hanging
* Fix `ls` not giving non-zero exit code on error
* Handle edgecase in is_atty
* Fix writer.flush() when there's no data
* Fix some tests
* Disable uv_unref on uv_process_t on Windows, for now.
* fix writer.end
* fix stdout.write
* fix child-process on win32
* Make this test less flaky on Windows
* Add assertion
* Make these the same
* Make it pass on windows
* Don't commit
* Log the test name
* Make this test less flaky on windows
* Make this test less flaky on windows
* Print which test is taking awhile in the runner
* fixups
* Fixups
* Add some assertions
* Bring back test concurrency
* shell: bring back redirect stdin
* make it compile again cc @zackradisic
* initialize env map with capacity
* some fixes
* cleanup
* oops
* fix leak, fix done
* fix unconsumedPromises on events
* always run expect
* Update child_process.test.ts
* fix reading special files
* Fix a test
* Deflake this test
* Make these comparisons easier
* Won't really fix it but slightly cleaner
* Update serve.test.ts
* Make the checks for if the body is already used more resilient
* Move this to the harness
* Make this test not hang in development
* Fix this test
* Make the logs better
* zero init some things
* Make this test better
* Fix readSocket
* Parallelize this test
* Handle EPipe and avoid big data
* This was a mistake
* Fix a bunch of things
* Fix memory leak
* Avoid sigpipe + optimize + delete dead code
* Make this take less time
* Make it bigger
* Remove some redundant code
* Update process.zig
* Merge and hopefully don't breka things along teh way
* Silence build warning
* Uncomment on posix
* Skip test on windows
* windows
* Cleanup test
* Update
* Deflake
* always
* less flaky test
* [autofix.ci] apply automated fixes
* logs
* fix uaf on shell IOReader
* stuff to make it work with mini event loop
* fix 2 double free scenarios, support redirections on windows
* shell: Make `1>&2` and `2>&1` work with libuv
* yoops
* Partial fix
* Partial fix
* fix build
* fix build
* ok
* Make a couple shell tests pass
* More logging
* fix
* fix
* Fix build issue
* more tests pass
* Deflake
* Deflake
* Use Output.panic instead of garbled text
* Formatting
* Introduce `bun.sys.File`, use it for `Output.Source.StreamType`, fix nested Output.scoped() calls, use Win32 `ReadFile` API for reading when it's not a libuv file descriptor.
This lets us avoid the subtle usages of `unreachable` in std.os when writing to stdout/stderr.
Previously, we were initializing the libuv loop immediately at launch due to checking for the existence of a bun build --compile'd executable. When the file descriptor is not from libuv, it's just overhead to use libuv
cc @paperdave, please tell me if Iany of that is incorrect or if you think this is a bad idea.
* Fix closing undefined memory file descriptors in spawn
cc @zackradisic
* pause instead of close
* Fix poorly-written test
* We don't need big numbers for this test
* sad workaround
* fixup
* Clearer error handling for this test
* Fix incorrect test
@electroid when ReadableStream isn't closed, hanging is the correct behavior when consuming buffered data. We cannot know if the buffered data is finished if the stream never closes.
* Fix build
* Remove known failing on windows
* Deflake
* Mark no longer failing
* show all the failing tests
* Sort the list of tests
* fix argument handling
* dont show "posix_spawn" as an error code on windows
* make bun-upgrade.test.ts pass on windows
* fix bunx and bun create again sorry
* a
* fix invalidexe because we should not be running javascript files as if they were exes
* Concurrency in test runner + better logging
* Revert "fix invalidexe because we should not be running javascript files as if they were exes"
This reverts commit da47cf8247.
* WIP: Unix fixes (#9322)
* wip
* [autofix.ci] apply automated fixes
* wip 2
* [autofix.ci] apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* Update runner.node.mjs
* Update runner.node.mjs
* Document some environment variables
* shell: Make `Response` work with builtins
* Make it compile
* make pwd test pass
* [autofix.ci] apply automated fixes
* Fix printing garbage for source code previews
* Update javascript.zig
* Fix posix test failures
* Fix signal dispatch
cc @paperdave. Signals can be run from any thread. This causes an assertion failure when the receiving thread happens to not be the main thread. Easiest to reproduce on linux when you spawn 100 short-lived processes at once.
* windows
---------
Co-authored-by: cirospaciari <ciro.spaciari@gmail.com>
Co-authored-by: Zack Radisic <56137411+zackradisic@users.noreply.github.com>
Co-authored-by: Zack Radisic <zackradisic@Zacks-MBP-2.attlocal.net>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Meghan Denny <meghan@bun.sh>
Co-authored-by: Zack Radisic <zack@theradisic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
* Make printing errors faster
* Make Next.js tests less flaky
* Update dev-server.test.ts
* Copy over runner from process pr
* bump next version
* Update javascript.zig
* Set port to 0
* p-queue
* no dont use docker buildx
* Prevent runner from hanging
* Update dev-server.test.ts
* Really fix hanging this time
* Fix bounds check for unix domain socket, support abstract namespace sockets
* Various fixes
* [autofix.ci] apply automated fixes
* Update runner.node.mjs
* Update runner.node.mjs
* windows
* Only care about stdout
* increase concureency + clean up test
* Tweak puppeteer
* Update runner.node.mjs
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* Bun.serve: error: pass Request parameter when available
* this will be null when not found not undefined
* add an assert here
* reorganize tests
* add another test
* add another test
* allow bun run to accept js from stdin
* document it
* fix window test
* cli/run: use printForLogLevel
---------
Co-authored-by: dave caruso <me@paperdave.net>
* empty trustedDependencies
* tests
* handle edgecases with default trusted dependencies
* could be zero length
* --trusted and skipped scripts
* resolver too
* second run --trusted
* --trust, better formatting
* more tests
* --trusted applies to dep deps, more tests
* progress
* fix build
* fix crash, make it look good, comments
* alphabetize, verbose log
* feature flag
* update lockfile
* update skipped text
* check update requests first
* be more careful with inline strings
* only with scripts
* fix tests, todo tests
* fix another test
* fix merge
* fix fix merge
* check binding.gyp for tarball and git resolutions
* remove dead code
* debug assert
* move newline printing
* use enum for `__has_install_script`
* oops
* clone packages
* Update src/install/install.zig
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* make bun-debug properly override `bun` in path
* windows path
* fix more issues with bunx
* sync
* stuff
* stuff
* f
* stuff
* further work
* a
* [autofix.ci] apply automated fixes
* okay
* fix building on posix systems
* ok
* make it so bun create cant crash + review
* docuemnt why return false is ok
* .
* cache bust
* merge
* yeah
* yea
* Update src/install/install.zig
* review results
* this will probably fix hardlink issue on windwo
* okay
* how did that work before
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* node:http: emit 'socket' event after calling http.request()
* add reference links for why this is how it is
* add guards to not waste time
* add a regression test
* use test harness port number
* node:url implement domainToASCII and domainToUnicode
* fix arg checks
* remove unneeded use of WTF::Vector
* tidy
* throw a js error if icu fails
* add a ton more tests, fix ascii guard, upconvert latin1
* even more tests
* add a comment for this guard
* use ASSERT_NOT_REACHED() instead of raise(SIGABRT)
* start some signal handling
* ok
* work on this from friday
* ok
* ref stuff
* threadsafety
* fix the buikld
* alright
* ok
* fix posix compilation error
* header fix
* revisions
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Zack Radisic <zack@theradisic.com>
* Updated `upgrade` to return error when used with cmd arguments
- Updated `upgrade` command to check for command-line arguments and return an error if so providing a suggested `update` command.
* added test
* updated condition to allow
* Upgrade argument check now only checks if all arguments contain `--`
- Added more tests
* Using `cpSync` in the following context results in an "Is a directory" error
* Update message displayed back to user
Co-authored-by: dave caruso <me@paperdave.net>
* moved args check to upgrade_command.zig
* fixed broken tests
* changing string interpolation to join() for paths
* [autofix.ci] apply automated fixes
* Fixed build errors
- Removed call to `std.mem.span`
- Added conditional to only run if there's more than 2 arguments (ignores the exec and `upgrade`)
- Added new test to ensure `upgrade` runs with 0 arguments passed
---------
Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* Slightly reduce number of system calls on Linux
* Fix regression from 648d5aecf3648d5aecf3 caused HTTP response bodies sent streamingly with a single chunk to include an extraneous 0\r\n\r\n chunk, leading valid clients to close the connection prematurely.
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* feat(options): add possibility to append a custom esm condition
* feat(cli): parse --conditions flag
* test: add case for custom conditions
* fix(cli): not get short-hand --conditions flag
* test: add case using cjs with custom condition
* fix(options): address possible memory issues for esm conditions
* refactor(cli): remove -c alias for --conditions flag
* test: add cases for multiple --conditions specified
* test(bundler): add support to test --conditions
* chore(cli): fix grammar mistakes in --conditions
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* windows: pass test/js/web/timers/setTimeout.test.js
* gotta go fast
* ci: windows: try reverting this line
reproducibly getting:
Error: Unable to download artifact(s): Artifact not found for name: bun-windows-x64-zig
* ci: switch back to namespace for zig build
* Use namespace.so for faster CI
* arm64 runners arent working
* deflake
* more
* Update bun-mac-x64-baseline.yml
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* okaaaaaaaay
* Revert "resolver: fix debug mode crash in test/bundler/bun-build-api.test.ts (#9140)"
This reverts commit 331d079dad.
* correctly fix the cache bust bug
this was introduced a couple of commits ago in my random fixes,
where i put the wrong fix to another directory caching bug.
i still stand by the assertion in place despite it causing many people
issues. it's precense will prevent subtle module resolutions failures.
* add an extra comment
* fix building a release build locally
* add a better test case for 3216
* staging
* fix mac issues
* ok
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* fix 9118
* update
* RELEASE_AND_RETURN
* cache and coerce
* test for toContainKey throwing in hasOwnProperty
* fix test
* [autofix.ci] apply automated fixes
* fix non-truthy and more test
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* Add test for ensuring the 'readable' event is emitted on end
* Run emitReadable on nextTick instead of as microtask
* perf: Store intermediate variables
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* Open with proper perms when redirecting file to stdin
* Add test for redirecting file to stdin
* Extract redirect flags -> bun.Mode logic to function
* Remove dead code
* Support duplicating output file descriptors
* Clean up
* fix merge fuck up
* Add comment documenting weird hack to get around ordering of posix spawn actions
* Update docs
* Delete dead code
* Update docs
* fix(ws/client): handle short reads on payload frame length
In the WebSocket specification, control frames may not be fragmented.
However, the frame parser should handle fragmented control frames
nonetheless. Whether or not the frame parser is given a set of
fragmented bytes to parse is subject to the strategy in which the client
buffers received bytes.
All stages of the frame parser currently supports parsing frames
fragmented across multiple TCP segments except for the payload frame
length parsing stage.
This commit implements buffering the bytes of a frame's payload length
into a client instance so that the websocket client is able to properly
parse payload frame lengths despite there being a short read over
incoming TCP data.
A test is added to
test/js/web/websocket/websocket-client-short-read.test.ts which creates
a make-shift WebSocket server that performs short writes over a single
WebSocket frame. The test passes with this commit.
* [autofix.ci] apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* Add `BUN_DEBUG` flag to control where debug logs go
* Update all the actions
* Configure temp
* use spawn instead of rm
* Use CLOSE_RANGE_CLOEXEC
* Make some tests more reproducible
* Update hot.test.ts
* Detect file descriptor leaks and wait for stdout
* Update runner.node.mjs
* Update preload.ts
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* Open with proper perms when redirecting file to stdin
* Add test for redirecting file to stdin
* Extract redirect flags -> bun.Mode logic to function
* Remove dead code
* [autofix.ci] apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* windows: implement bun.isWritable
* windows: pass test/cli/run/as-node.test.ts
C:\Users\dave\AppData\Local\Temp\bun-node-a2ae984c3\node.exe is a hardlink on windows so it will not resolve to C:\bun\build\bun-debug.exe
skip the first param since that is not the behavior this test is supposed to be testing
* windows: pass test/js/node/dns/node-dns.test.js
* windows: pass test/js/node/process/process.test.js
* windows: pass test/js/web/streams/streams.test.js
* windows: pass test/js/workerd/html-rewriter.test.js
Closes#8459
* windows: fix node:util.inspect
* windows: these pass now
* windows: pass test/js/node/stream/node-stream.test.js
* disable http sendfile on windows
* use url.origin here
* more sendfile removal
* windows: pass test/js/web/websocket/websocket.test.js
* test/js/deno/performance/performance.test.ts is flaky, come back to it
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* fix: make sure Bun.sleep(Date) doesn't return prematurely
Fixes#8834.
This makes Bun.sleep(new Date(x)) fulfill its promise only when
Date.now() >= x.
* resolve test now #8834 is fixed
11 ms is in fact the right limit.
---------
Co-authored-by: John-David Dalton <john.david.dalton@gmail.com>
* Add fs.exists[util.promisify.custom]
fs.exists doesn't follow the error-first-callback convention, so it
needs a custom implementation for util.promisify.
* Simplify
---------
Co-authored-by: John-David Dalton <john.david.dalton@gmail.com>
* Fix#8403
* Throw on error by default
* Add the shell promise utilities to `ShellOutput` and `ShellError`
* Fix tests
* [autofix.ci] apply automated fixes
* Fix memleak
* [autofix.ci] apply automated fixes
* Woops
* `Bun.gc(true)` in fd leak test
* fd leak test should check if `fd <= baseline`
* wtf
* oob check
* [autofix.ci] apply automated fixes
* Fix double free
* Fix#8550
* increase mem threshold for linux
* Requested changes and make not throw on by default
* [autofix.ci] apply automated fixes
* more requested changes
* Do destructuring in function definition
* delete
* Change shell output test to enable throwing
* [autofix.ci] apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* Bun.inspect: distinguish [Getter], [Setter], [Getter/Setter]
fixes#8853
NOTE: this modifies files which were auto-generated at one point, but
which are now maintained as part of the Bun sources.
* test for #8853
---------
Co-authored-by: Georgijs <48869301+gvilums@users.noreply.github.com>
* try to make ci green
* fix a crash in debug mode
* [autofix.ci] apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* random acts of cleanup to tests
* nerf the watchFile test, is CI slow?
* more things
* [autofix.ci] apply automated fixes
* a
* remove a log
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* fix: zlib functions should throw an error if appropriate
Fixes#8887.
* Tests for #8887
* fix: drive-by fix to avoid unreachable code being reached on error
* work on bundler
* a
* YAAAAYYAYAYAYYAYA
* get some more bundler tests working
* Update src/bundler/bundle_v2.zig
* rev
* ok
* i converted the cmakelists into LF
* personal review
* we didnt win
* okey they pass
* revert :(
* a
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* Remove dead code now that `expect()` can be used outside of tests
* Fix some errors not being rendered to GitHub annotations
* [autofix.ci] apply automated fixes
* Update jest.zig
Try `execCallback`
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This often fails in CI (and on my machine) non-deterministically.
The 1ms + the 5000 is likely setting up a race condition in tasks/microtasks. Just changing it to to +10ms instead of +1ms is enough.
* http use arraylist to handle shutdowns
* on windows use wsaconnectbyname to speed up localhost connections
* use arbitrary port
* close socket on setsockopt error
* use null timeout in wsaconnectbyname
* Update src/http.zig
* fix zig compile
* update hostname on linux
* [autofix.ci] apply automated fixes
* fix getpeername failing after connecting with socket
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* Add checks that we drain the microtask queue whenever we call into JavaScript
* Drain microtasks in more places
* Tweak assertions for entering/exiting the event loop
* Drain more
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* uv loop is thread local
* hi
* stuff so far
* [autofix.ci] apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Binary notation ("0b") is appropriate instead of hexadecimal notation ("0x").
Sorry for the omission of the correction in this [PR](https://github.com/oven-sh/bun/pull/8619).
* get test/bundler/bundler_naming.test.ts passing on windows
* move platformToPosixInPlace to bun.path and use the vector'd version
* only resolve rel_path if it contains '/./', most of the time './' needs to be preserved
* fix another file too
* move kernel32 extern to better location
* [autofix.ci] apply automated fixes
* use bun.path.posixToPlatformInPlace here
* rewrite this whole section to stay in utf16 and handle errors
* remove dead comments
* fix a typo
* undo these relative changes
* preserve path.pretty from getting lost
* use bun's instead of zig's resolve here
* both side of this loop need the inplace normal
* use existing generic dirname function
* make path inplace functions generic
* we might need to modify this so copy on windows
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* don't assume the prefix we get from this
* more robust path traversal
* don't mangle absolute paths
* do this bit in a loop
* this line is a u16
* dont forget to compile before pushing
* this was wrong
* look into this later
* check pointer math first since its faster
* posix syscalls support path traversal, don't do the work for them
* its already inside stable, no need to change
* used the online editor
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* draft impl of windows watcher
* synchronous watcher
* working standalone watcher
* in progress changes to watcher
* make watcher non-global
* prepare watcher for windows impl
* add windows watcher scaffold and clean up imports
* fix inotify
* make watch code more generic over platforms
* fix visibility
* watcher starts without error
* printing changes works
* basic windows watching works
* handle process exit from watcher
* cleanup in process cloning
* clean up logging and panic handling
* fix hot reload test on windows
* misc cleanup around watcher
* make watch test actually useful
* [autofix.ci] apply automated fixes
* remove old files
* clean up watchers
* update .gitignore
* rework windows watcher into single watcher instance watching top level project dir
* use non-strict utf16 conversion
* change to contains
* fix mac and linux compile
* add baseline in crash report (#8606)
* allow linking bins that do not exist. (#8605)
* fix linux compile
* fix linux compile (again)
* remove outdated todo
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
* yay!!!!!!
* [autofix.ci] apply automated fixes
* ok
* do not use reflect here
* ok
* [autofix.ci] apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* Docs: Fix typo in code example for transformSync
* Remove await since transformSync is synchronous
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* link and unlink
* valid git dependency cache path
* windows global link
* not git
* update some tests
* update more tests
* update
* update log
* fix snapshots
* more tests
* fix bun pm ls
* make it possible to delete cache dir
* normalize
* fix bun-create tests
* update bun-remove tests
* silent
* bun-run update
* update more tests
* update more
* update
* [autofix.ci] apply automated fixes
* update simdutf for getFdPath
* update test
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* shim v1 TODO
* fix BunXShimData
* wip
* put a little bit of the sa u c e on it
* wow
* wat
* a
* swag
* swag
* allllllllllllright
* Update src/install/bin.zig
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
* [autofix.ci] apply automated fixes
* swag
* swag
* finis
* fix submodules
* ok
* omg it works again
* silly
* ok
* OK
* update laucnh jsn
* swaaaaaaaaaaaaag
* remove debug
---------
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
When using sendfile() to stream, if the user aborted the request it may appear as `ENOTCONN`, which we were logging to the terminal. We really shouldn't be logging anything here, but it's a little unclear what kind of error to emit. It's not a fatal error.
* fix argv parsing on windows
* directly use zig stdlib
* remove debug comments, fix double deinit
* change bun.argv() to return slices, not null-terminated pointers
* fix test on windows to escape file paths correctly
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* windows: fix some websocket tests
* this file should work now, report any errors
* make this change later
* add back running this with node
* add as const to these
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* fix sys.dup on windows and make console-iterator work
* fix(windows): fix console async iterator to not include the \r
* fix kill on windows again. and report the right errno
---------
Co-authored-by: dave caruso <me@paperdave.net>
* Move ReadFile and WriteFile to separate file
* Use libuv for Bun.write()
* Update windows_event_loop.zig
* build
* Get bun-write tests to pass. Implement Bun.write with two files.
* UPdate
* Update
* Update failing test list
* update
* More
* More
* More
* More
* Mark the rest
* ok
* oops
* Update bun-write.test.js
* Update blob.zig
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Dave Caruso <me@paperdave.net>
Co-authored-by: Georgijs Vilums <georgijs.vilums@gmail.com>
ioctl_ficlone may return EPERM (in LXC container), EACCESS (in Android).
Those error should be taken as ficlone being not supported instead of
error.
Refer to this coreutils bug report https://bugs.gnu.org/62404
* keep cache dir path, use correct buffer
* make it work more better
* more working
* more fix
* more update
* more fix
* fix test
* update
* fix
* update pointers
---------
Co-authored-by: dave caruso <me@paperdave.net>
* keep cache dir path, use correct buffer
* make it work more better
* more working
* more fix
* more update
* more fix
* fix test
* update tests
* comment and fix test
* one more fix
* fix build
---------
Co-authored-by: dave caruso <me@paperdave.net>
* spawn sync investigation, pipe closed before uv_read_start is called
* oopsie
* win rusage
* oopsie
* Fix some things
* readable stream now works without FIFO like solution
* blob, ArrayBuffer, Buffer stdin now works
* remove unused
* add UVStreamSink
* update headers.j
* more bindings
* now works yay
* fix rusage on windows
* oops
* fix rare data
* win getUserName
* [autofix.ci] apply automated fixes
* fix build
* oopsie
* fix linux/macos
* exit code fix
* fix kill for win
* disable Bun__crashReportDumpStackTrace on Windows
* remove windows stack dump in report.zig and increase windows test timeout
* condition instead of assertion
* remove IPC again
* fix blob writer when not using TTY
* bump windows tests time again
* bump time again so we see how much we need (this is probably too much)
---------
Co-authored-by: cirospaciari <ciro.spaciai@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: cirospaciari <ciro.spaciari@gmail.com>
* copy_file: this TODO is no longer a compiler bug
* [autofix.ci] apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* bring in shell impl
* add `$` to global bun scope
* Expose shell parse func on debug mode
* Expose lex tokens and add tests
* refactor parser to have better ast
* assigns and export
* pipeline kinda working
* Decouple Subprocess spawning code from JS stuff
* Subprocess works!
* Conditional execution
* Support JS objects in template expression
* More complete redirection
* Properly drain stdin/stdout/stderr and fix crash from deallocating JSC memory
* Return errors in parser
* Support command substitution
* wip brace expansion stuff
* Rearrange some files
* expansion wip
* Brace expansion working
* wip brace expansion
* refactor brace algorithm
* wip brace expansion on shell
* fix brace expansion
* Working nested brace expansion!
* brace expansion in shell variable assignment only set the last expanded
* stuff
* Small little perf things
* benchmark and test and stuff
* stuff
* fix nested braces but its also kinda broken
* attempt to fix complicated nested braces
* test
* Use fast tokenized algorithm for non nested braces, use parsed algorithm for nested braces
* fix nested braces one and for all
* small stuff
* Not sure if that made a difference
* revert that
* good speed optimization
* rip
* Environment variables, builtin/native shell cmds
* Fix tests
* Support `cd`, `pwd`, add boilerplate for glob expansion
* Support `which`
* Support `rm`
* wip
* wip
* escaping and abstract shell char iterator
* strpool unicode
* Brace expansion support unicode, disallow invalid surrogates in shell script
* shell choose ascii or unicode lexer depending on input
* fix bugs write tests
* kinda start async stuff
* HOLY SHIT big refactor of Subprocess
woops forget to commit this
...and this
* HOLY MOLY it works
* Refactor some stuff, start eval word expansion
* interpret all the nodes
* stuff
* stuff
* stuff
* kind of works but doesnt
* Buffered output works
* no need to heap allocate autosizer
* Fix bug
* Fix some stuff
* unprotect
* move out dummy shell thing
* Bring back assignments
* create expansion state so it can be non blocking for expansions that need IO (glob, cmd subst)
* glob back in action
* Setup builtin non blocking IO commands and implement export
big issue is control flow is really fcked up here need to fix that
* make Cmd state machine use a loop so control flow is a bit more clear
* rename stuff
* move that
* Implement the echo builtin again
* implement cd again but non blocking io
* Fix ls and use proper write function to prevent blockign writes
* Implement which
* holy moly big port std.fs.deleteTree
* fix compile errors
* Okay that works
* rm works thatsnice
* damn
* split it out
* rm async implementation
* fix rm bug for nested
* Work on files as well
* prevent root from being deleted
* rm error handling
* oops
* pwd and fix some script exec bug
* Implement `mv`
* stub out mv to work accross filesystems
* move it around
* woops
* boilerplate for ls and options
* more boilerplate
* stuff
* that got lost in merge
* upgrade shell stuff zig 0.12.0-dev.1828+225fe6ddb
* Implement basic ls
* smol cleanup
* Fix stream, response redirect stdin
* No longer need spawn to be abstract
* Custom promise
* move around some stuff
* shell promise returns shell output
* make tht work for builtins
* refactor IO abstractions to work with JS or mini event loop
* woops
* scaffolding for refactor
* refactor builtins to make event loop refactor easier
* Fix parsing edge case on assignments, fix expansion on cmd assignments
* change subproc to work with any event loop
* Finish refactoring subproc
* move global abstraction out
* big refactor boys
* holy moly: integrate into cli and fix allll the compile errors
* okay works in bun run now
* actually tick the event loop lol
* Fix more stuff
* Support comments
* Fix some tests
* delete that
* Properly report errors when failing to spawn command
* fix a whole bunch of tests
* fix a whole bunch of tests again
* .
* Fix rm
* Fix some exit code bugs, write force rm from deno, fix ls stderr
* fix `rm -d`
* fix `rm -d`
* Fix boolean logic
* error on subshells (e.g. `true && (echo hi && echo lol)`)
* Move out shell state from interpreter struct
* Cmd substitution supports arbitrary script, not just a single cmd
* Some escaping/quotation tests
* Fix stuff add more tests:
- cmd substitution quotations
- escape backticks in single quots
* ALOT of stuff:
- fix proper subshell inheritance of env for cmd subst
- fix: was wrong, assignments don't run in subshell in conditionals
- fix lexing chained vars `$VAR$VAR`
- more tests
* Fix subtle bugs
* Fix crazy redirect to arraybuffer bug
* more crazy echo edgecases
* Proper lexer errors instead of just panicking lol
* yoops
* Proper parsing errors
* Errors for bun run shell script
* Fix redirecting to file
* More test fix bugs yay
* Fix redirect on builtins
* Open redirection fds with O_TRUNC
* Fix lexing invalid variables and add ability to change cwd from JS api
* yoops
* Fix `.cwd()`
* `$PWD` and fix redirection bugs
* `$PWD` and fix redirection bugs
* Get rid of some `FIXME`s
* throw errors in some places instead of panicking
* Print some errors to stderr
* Get rid of some more panics again
* Handle errors on glob
* pwd test
* `.env()`
* copy-on-write abstraction
* Reference counted env strings + fix some tests
* deinit cwd
* Put commands into a pipeline properly
* deinit Expansion and Assigns properly
* comments
* Comments
* Make it compile
* Update types
* [autofix.ci] apply automated fixes
* Only one WaiterThread
* Fix lifetimes and clean up interface
* Update shell.ts
* Add lazy test
* Remove some dead code
* Update shell.zig
* Fix memory leak
* Fix crash with empty braces
* [autofix.ci] apply automated fixes
* Linux build + bun.sh
* Update subproc.zig
* Update interpreter.zig
* Update interpreter.zig
* Fix some stuff that broke
* Fix Windows compile errors
* Fix some fd leaks
* Fix ls
* Fix a bunch of stuff
* Fix quiet
* Update leak tests fix rm bug
* More reproducible tests
* [autofix.ci] apply automated fixes
* more mem leak tests
* [autofix.ci] apply automated fixes
* Fix merge conflict
* Fix test not actually using temp directory
* Update bunshell.test.ts
* Shell instance
* Capture async context
* Increase test timeouts
* [autofix.ci] apply automated fixes
* Escape
* [autofix.ci] apply automated fixes
* Fix crash
* Add more methods
* [autofix.ci] apply automated fixes
* Fix leak
* Treat file(path) blobs as a file path string
* Create bunshell-file.test.ts
* Support Blob input
* Fix leak + organize imports
* doc
* Update shell.md
* Update shell.md
* Update shell.md
* Update shell.md
* Update CMakeLists.txt
* Fix segfault by cloning error path so it's not freed by arena
* deinit ShellErr
* Delete dead code
* fix really stupid segfault
* don't deinit shell ls task in event loop
* Fix ls bug
* Fix tests
* make truly lazy
* allow more things in the shell substitution and escape whitespace
* Fix newline and exit when finishing shell in `bun run`
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* In fs.ReadStream, use `$isObject` to check if function or object rather than typeof options === "object"
* Update fs.js
* Add test
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* Avoid deadlock in messageWithTypeAndLevel by adding a recursion counter
* Add test for recursive logs
* Do not rely on output of console-recursive.test.js
* [autofix.ci] apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* make node:fs/promises.open return a FileHandle and expose fdatasync
* node_fs: add fn spacing
* fix this assert usage too
* move primordial preservation higher
* use expect().toBe() instead of assert
* ensure top level node:fs/promises functions always receive fd's as a number
* add needed fixture
* [autofix.ci] apply automated fixes
* this was the wrong fix for a different thing
will look into it later
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* port 'initial support for using declarations'
1:1 port of this commit:
56a3e01244
* port 'initial support for await using declarations'
1:1 port of this commit:
1634a0b5ad
* fix cmake config for local jsc
* add global defines for symbols
* begin porting lowering implementation
based off of
https://github.com/evanw/esbuild/pull/3192
* [autofix.ci] apply automated fixes
* add some fun webkit scripts
* fix the minification bug
* refactor runtime_js, etc
* rename test file
* finished yapping
* silly silyl
* Update src/bundler.zig
* ok
* a
* Fix crash
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* exit event loop if there's unhandled errors
* move FixedQueue to a special package
* require(events) is also EventEmitter
* implement events.on
* move fixed_queue to internal and make it lazy in node:events
* use better Promise intrinsics
* move $shared to internal/shared
* make test not dependent on cwd
* Some windows tweaks
* Make this pub
* Update bundle_v2.zig
* Fix woopsie
* Make this error better
* Add assertion for using allocator for HTTP client from another thread.
* Do fewer copies in readdir()
* Fix crash/failing tests
* Update tests
* Fix windows build
* Update loop.c
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* Upgrade uWebSockets & usockets
* Update HttpRouter.h
* Defensively prevent sending to blocking sockets
* Add test for receiving large amounts of data
* Large data optimization
* Update loop.c
* Avoid extra system call before entering event loop
* Update internal.h
* 1 less pointer lookup
* Fix error
* Update socket-huge-fixture.js
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* remove while loops where a for would be more efficient
* this needs to be a stack copy
* this can use the better loop
* this was translated wrong
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* fix(node:url): handle url with missing host on `url.parse`
* lazy load punycode module
* use URL class
* add comment and also extra sanity check tests
* extra test
---------
Co-authored-by: dave caruso <me@paperdave.net>
* all: make bun.FileDescriptor a unique type
# Conflicts:
# src/bun.js/api/bun/socket.zig
# src/bun.js/api/bun/spawn.zig
# src/deps/uws.zig
* need this change too
* convert another bun.FD.asDir call
* more fixes + linux
* fix this size
* accidentally flipped these fd numbers
* more fixes + windows
# Conflicts:
# src/deps/uws.zig
* dont include type name in serialization
* add another TODO
* resolve review comments
* address more pr comments
* build fixes post-rebase
* another rebase fix
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* Fixes#7001
* One more test
* Use `disturbed`
* [autofix.ci] apply automated fixes
* Fix failing test
* Test is no longer todo!
* Make bodyUsed work too
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* fix compilation and types for FD option using usockets
* comment
* clarify HOST_MAME_MAX on windows
* use libuv for timers on windows
* [autofix.ci] apply automated fixes
* fix linux build
---------
Co-authored-by: cirospaciari <ciro.spaciai@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* Don't use posix_spawn on Linux
* Make it work
* Avoid closing inherited file descriptors
* Hopefully fix test failures
* Reset close-on-exec flag
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* implemented assert.doesNotMatch
* fixed assert.match and assert.doesNotMatch tests and ensure it throws when actual is not a string
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* Update contributing.md
Added documentation for the installation of the perl Math::BigInt module
* Update contributing.md
merged the fedora perl math bigint module with the other dependencies
* Fixes#8010
* Update install.zig
* Copy the metahash when cleaning the lockfile
* Save more, but error less
* Change copy when there are no more dependencies
* Tweak some tests
* Update bun-add.test.ts
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
const result = await ...
for (const result of result.outputs) {...
throws
const result = await Bun.build({
^
ReferenceError: Cannot access uninitialized variable.
* Add test for multiple partial consume from BufferList
This shows the problem indicated in #7385
* Fix multiple partial consume from BufferList
The JSUint8Array::possiblySharedBuffer() returns the backing array,
not taking into account the byteOffset that indicates the start of
the data in the backing array. This means that when creating an array
with the same backing array, the current byteOffset needs to be added
to the start of the new slice.
This led to consume() returning the same data when repeatedly consuming
small numbers of bytes from the BufferList.
* Add Scoop installation for Windows
* Update installation.md
* update powershell/cmd
irm is used because on certain installs of Windows 10 iwr does not work because of something related to Internet Explorer. haha~
---------
Co-authored-by: dave caruso <me@paperdave.net>
* node:child_process: support defining extra pipes
* unneeded
* lazily load node:fs
* use $isJSArray instead of ArrayIsArray
* remove std.log call
* don't close child fd we don't own
* close child fd's in parent
* add Subprocess.stdio getter that aligns with ChildProcess.stdio fd's
* [autofix.ci] apply automated fixes
* use ArrayList instead of BoundedArray for stdio_pipes
* fix stream primordials
* dont use unreachable for syscalls
* this file was testing Bun.spawn not child_process.spawn
* skip ipc for now
* ensure the socketpair is created non-blocking on non-mac posix
* allow creating a node:net.Socket from an fd via node:net.connect
* node:stream tidy
* node:child_process: use net.Socket for stdio instead of fs streams
* try again
* fix Socket eager loading
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* Add brotli test
* Check if we can use brotli
* vendor brotli
* Update .gitattributes
* Brotli is now always available
* Update licensing.md
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* [bun:sqlite] Don't call memcpy on a 0 length value or nullptr
* [bun:sqlite] Add missing flags argument
* Make this a reference I guess
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* Tweak alignment of console.table
* " " empty string instead of "#"
* Fix assertion failure
* Only get the length when necessary
* Avoid stale copies
* Add `asUTF8` helper to `bun.String`
* Cautiously handle recursion
* Further tweaks to output
* output
* Add native implementation of `getStringWidth`
* [autofix.ci] apply automated fixes
* If its not a string then quote it by default
* Add snapshot for headers
* Make it easier to debug when a builtin throws an exception
* This must be hoisted
* Fix bugs in `getStringWidth`
* Update getStringWidth.test.ts
* Eager load it
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* Better errors for bun:sqlite
* Add `byteOffset`
* Add `code` property
* Fix error
* Update test
* Add a couple more tests for errors
* Add file with sqlite error codes
* Report extra memory from `sqlite3_stmt`
* Add polyfills for macOS x64
* Use -1 when unavailable
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* docs(bundler): update CLI command in index.md for bun build with publicPath
* Update docs/bundler/index.md
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* Fix crash with latin1 supplemental characters in bun:sqlite queries
* Make it run from any dir
* Fix comment
* [autofix.ci] apply automated fixes
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* scripts/setup.sh: don't check for zig since it installs zig later
* [autofix.ci] apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* fix(#7740): change 'Duplicate dependency' to be warning instead of error
* chore(07740.test.ts): clean up test
* [autofix.ci] apply automated fixes
* fix(src/logger.zig): increment warnings instead of errors in addRangeWarningFmtWithNotes()
* chore(07740.test.ts): simplify package.json to avoid increasing test times
* chore(bun-install.test.ts): update test to expect 'warn' instead of 'error'
* chore(07740.test.ts): fix formatting
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
These are two important packages for purescript development, purescript is the language (including a binary file that must be installed), and spago is the purescript package manager (also including a binary file that must be installed).
* Simplify string handling code
* add extra + external
* Update fs.test.ts
* Bump
* woopsie
* prettier
* Rename stats() to resourceUsage()
* Fix leak
* Fix more leaks
* Setup malloc heap breakdown
* Thread safety
* Fix bug when creating buffer from utf-16 string
cc @dylan-conway
* Use global allocator
* More new
* Update fs.test.ts
* Update setTimeout.test.js
* Fix UAF in HTMLRewriter
* More bun.new
* Remove logs
* Un-skip test which no longer is flaky
* Even more `bun.new`
* Fix memory leak in HTMLRewriter.
Fixes#2325
* Don't accept Buffer for now
* Fix issue with node-fetch polyfill
* Don't destruct the response value too soon
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* napi fixes
* Make bcrypt work
* Always return this
* Fixes#7685
* [autofix.ci] apply automated fixes
* Update napi.cpp
* Make it clearer what this is doing
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* Use timer heap for `setTimeout`
* Further efficiency improvement to timers
* Fix assertion
* Make this test less flaky?
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* change how exit codes and signals are printed
* second iteration of this
* [autofix.ci] apply automated fixes
* dasfsa
* Fix Linux Build
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* More lkogs
Add more logs for `--verbose`
* Fixes#5792
This makes `--frozen-lockfile` use a hash of all the resolved package versions that were installed, instead of the more permissive logic used to decide whether or not to re-run the install
* Fix debug assertion failure in `bun install --production`
* Update src/install/install.zig
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
The postinstall script will never print anything, since it does not exit with a non-zero exit code.
Therefore, this warning will never have an impact
Therefore, it should not be allowed to increase how long it takes to install your packages
4436cc748c/scripts/postinstall.js
* chore: upgrade zig to 0.12.0-dev.1828+225fe6ddb
* open as iterable
* fix building identifier cache
* fix windows build
* fix linux build
* fix linux build
bump to "657558d4d4c9c33f41b9670e72d96a5a39fe546e" which has some
windows-specific fixes, as well as fixes linux-arm64 debug build,
and adds the debug windows build.
* Use EdgeQL `for` expression for bulk insert in seed.ts
Perhaps this was a JavaScript for loop before to make it a little easier to grok for non-EdgeDB users. However, hopefully this is easier enough to understand that people can still follow the example even if they do not know EdgeQL.
* Fix small typo in assignment
* Support `expect().toBeValidDate()`
* Support `expect().toContainEqual()`
Also fixes a bug where `expect(new Set()).toContain()` would not work
* Update expect.zig
* docs
* [autofix.ci] apply automated fixes
---------
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* fix(win/upgrade): do not show powershell expand-archive info while upgrading
* start working bun run
* experiment: `bun.new`
* you can now bun run
* Update src/install/install.zig
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* Update src/install/install.zig
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* stuff
* fix stuff
* fix this
* farther but not really
* sadfs
* path hell
not sure how much worse or better this makes things. its a mess. windows path handlign is a mess aaaaaaaaaaaaaaaa
* path.resolve bs
* remove old build system stuff from pr
* a
* fix some path.parse/join cases
* path closer not perfect
* normalize and join tests tests done
* paths
* implement path.relative
* ,
* stuff
* assert
* fix compile
* hate
* the code isnt great
* stuff
* housekeeping for build system
* blah
* explain windows sitaution in docs
* some progress? not much though
* zig compiler crashes here
* fix
* yippee
* ok
* a
* ala wala
* fix builds on stuff
* clean
* the tests now run
* a
* aa
* dedupe uv event loop
* fix fs test accuracy
* stuff
* [autofix.ci] apply automated fixes
* huge updat e
* [autofix.ci] apply automated fixes
* url
* [autofix.ci] apply automated fixes
* start windows spawnSync
* [autofix.ci] apply automated fixes
* add --webkit for update submodules
* add better err message for `bun setup`
* fix unix platform build
* .
* [autofix.ci] apply automated fixes
* un-upgrade libarchive
* z
* asdfghj
* wrk
* todo -> panic
* ok
* a
* [autofix.ci] apply automated fixes
* fix build scripts l ol
* dfghj
* fa
* [autofix.ci] apply automated fixes
* aaaa
* a
* l
* [autofix.ci] apply automated fixes
* more logs
* [autofix.ci] apply automated fixes
* j
* fix init_command
* CORE DUMP HELL
* i swear im being pranked by the github actions gods
* fadsjkfdshjkhjkdfsahjkdfshjksdafjkhhjkfdsahfsdkjhfsdjkahf
* thanks IAS
* this is the correct fix
* personal review
* ddisablbe these
* revisions!
* ok
* fix submodule
* stuff
* fix libarchive
* [autofix.ci] apply automated fixes
* stuff
* [autofix.ci] apply automated fixes
* a
* fix addressToJS on windows
* make dns async again
* dx: add flag to update submodules ps1 to clone webkit
* dns error case for libuv
* dx improvements on windows
* newline
* obvious fix
* install steps
* extra note
* fix fs test
* Update building-windows.md
* fix builtins bundler to support \r\n line endnigs
* better
* some windows stuff
* a
* a
* a
* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
* [autofix.ci] apply automated fixes
* bunfile text works
* fix build on the mac
* hellooooooooooo
* install steps
* ci for baseline?
* fix
* aaa
* wow
* install script revamp
* bug
* OK
* ok
* aaaaaaaaaaaaaa
* okay
* fix the node test runner lol
* fix napi stuff
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: cirospaciari <ciro.spaciai@gmail.com>
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
* Move code for lifecycle scripts into a separate file
* Fix slow & incorrect pipe reading code used for bun install lifecycle scripts
* Fix crash in IPC due to calling on_socket_long_timeout when its a null ptr
* Only try to get the node path one time
* Fix incorrect glob pattern for rebuilding Zig files
@paperdave doing `**/**/**` does not work
* Implement basic support for ioctl_ficlone
* lowercase these
* intcast
* This is backwards
* Fix "waiting for tasks" spam
* Update install.zig
* Add helper
* Update install.zig
* Address PR feedback
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* [install] allow parallel execution of `postinstall` scripts
- fixes spurious exit code 42 from `spawn()`
* postinstall to a pipe
* feat(install): include top 500 packages as defaults for postinstall
* windows newline handling*
*i did not test it
* stuff
* cool
* a
* fix merge
* set `has_trusted_dependencies`
* fix a bunch of tests
* fix merge
* remove `PackageManager`
* remove commented code
* change to function
* Update lockfile.zig
* run scripts if added to `trustedDependencies` after install
* packages without `resolved` properties
* node-gyp scripts
* node-gyp script in the root
* another test
* git deps run prepare scripts
* fix merge
* run lifecycle scripts during installation
* Update lockfile.zig
* always increment
* 🏗️
* update tests
* tickWIthoutIdle
* const uws
* loop forwards through trees
* single buffer bitset list
* tag.isGit
* windows path separators
* `bun.sys.read` and enable/disable buffering
* fix test and waiter thread
* waiter thread and tests
* Update bun-install-registry.test.ts
* workspace exclude `preprepare` and `postprepare`
* Create esbuild.test.ts
* make sure length is the same
* remove deferred binlinks, add estrella test
* test with another version
* address some comments
* remove .verdaccio-db.json
* ooops
* fix build
* use `pid` to wait
* dont register pid_poll when using waiter thread
* stress test
* free
* fix failing tests
* fix linux crash, snapshot stress test
* oops
* concurrent scripts
* activate as soon as possible
* test
* delete stress test packages
* remove unused packages
* comment stress test and maybe fix segfault
* delete snapshot
* fix assertion
* use cpu_count * 2 for default concurrent scripts
* gear emoji
* add --concurrent-scripts to docs
* more docs
---------
Co-authored-by: alexlamsl <alexlamsl@gmail.com>
Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: Dylan Conway <33744874+MilesWright7@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* use lockfile path passed as an argument instead of a literal string
* clean up tmp folders in migrate.test
---------
Co-authored-by: Alex See <alexsee@Alexs-MacBook-Air.local>
* Clean up control flow in Bun.file().* file reader
* Preallocate large files on Linux
* remove `this.wrote` field
* push
* doesnt work yet
* Create if not exists
* Fix for macOS
* Update blob.zig
* Slightly clean up this test
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* Fix parseArgs issues and reenable it
* Minor changes to parseArgs
* Another minor change to parseArgs
* Add exception handling to JSValue putMayBeIndex
* WIP rewrite IO for Bun.file()
* It seems to work on macOS
* Update ffi.zig
* Handle many more cases
* Clarify this more
* More comments
* [autofix.ci] apply automated fixes
* Add empty
* Make it work in epoll
* fetch fixes + tests fmt
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: cirospaciari <ciro.spaciari@gmail.com>
* feat(test): allow file paths to test specific files.
* [autofix.ci] apply automated fixes
* be less stupid about what files the CI runs as tests
* aa
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* Faster napi
* Reduce number of headers exposed for JSStringDecoder
* Add missing header
* test: this test was meant to be marked as TODO
* revert the string decoder garbage
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
There is no reason to have the entire install stage for the
prerelease stage. Instead use the base as base and copy
in the relevent files (which already happened)
* Parse stack trace string
* Syntax highlight error messages
* Fix off-by-one
* Undo changes to populateStackTrace
* Highlight more things
* Add a way to write tests for it
* Create highlight-cat.ts
* Bump
* fix: off by ones
* feat: add function highlighting to these errors
* revisions
* undo
* l
* fix webkit submodule
* imo this looks worse
* [autofix.ci] apply automated fixes
* fix off by one <3
* fix more situations
* ch changes
* ok
* [autofix.ci] apply automated fixes
* fix this
* fix snapshot
* ok
* mark test as todo
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* idk why that was left out
* No need for stat call, add text for broken symlinks
* tests for crashes
* Fix test
* Add some checks to limit max open file descriptors
* Update glob.zig
* Update glob.zig
* Update scan.test.ts
---------
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
* improvements
* autobahn tests
* add all tests
* check if docker is active move autobahn to a new file
* fix non SIMD UTF8 validation
* use no trim to catch utf8 issues
* fix extended payload fragmentation
* fmt
* Update src/string_immutable.zig
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* bun-test expect.extend and asymmetric matcher improvements
* [autofix.ci] apply automated fixes
* Changes to expect.extend and asymmetric matchers
* expect-extend: remove global custom matchers registry
* test custom matchers: better way of storing matcher func
* made expect.arrayContaining/objectMatching reject non-arrays/non-objects
* [autofix.ci] apply automated fixes
* fixes for test changes
* create 1 wrapping function instead of 2 per each custom matcher
* fix expect.extend error messages and support for async matchers
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* Mark require as private
* [autofix.ci] apply automated fixes
* fix(runtime): clean up cjs + stack trace stuff
- CJS wrapper is like 200x simpler to understand. it is also 1-10% faster
- Make a few more things hidden in stack tracess. This only affects release build.
* [autofix.ci] apply automated fixes
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
* feat: use trailing commas when printing multi-line objects
* test: update console-log.expected.txt to include trailing commas
* test: update a couple tests to match new object output with trailing commas
* [autofix.ci] apply automated fixes
---------
Co-authored-by: Alex See <alexsee@Alexs-MacBook-Air.local>
Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Even though I had run the export, `bun setup` was erroring with:
```
$ ./scripts/setup.sh
setup error: LLVM 16 is required. Detected CXX as '/usr/bin/clang++'
error: script "setup" exited with code 1 (SIGHUP)
```
Running `export PATH="$(brew --prefix llvm@16)/bin:$PATH"` fixed the error
* Quote export aliases with hyphens when converting jsons to modules
* Add test
* Handle quotes in printer and not in bundler
* [autofix.ci] apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* dx: automatically install and update zig
* update repo
* ensure system zig compiler in ci
* a
* b
* good
* i am stupid
* why did this happen
* fix installer
* fix: only write header if not exist
If user set header by himself, then we not write duplicate header.
* feat: add test to check header
* chore: format code
* initial glob impl
* Add `Bun.globMatch`
* Glob boilerplate setup
* Experiment with Rust glob implementation
* Rust impl is slow revert
* Setup glob walking
* Basic glob walker working
* Fix segfault
* Recursive directory traversal
* Fix glob match non-ascii
* Make faster lil bit
* use arena
* ASCII fast path
* Experiment with packed codepoint cursor
Results in ~4% perf boost if the glob pattern needs to create/manipulate cursors (for example when the pattern uses braces)
* Try converting to u32 array
Made it pretty slow
* Lazily create codepoint buffer
* Different walk algorithm
* Fast path optimizations
* Add `dot` option to `Glob`
* .
* Fix some bugs
* Fix bug, clean up lil bit
* Windows fix
* Non absolute paths
* use specific version of fast-glob for benchmarks and tests
* .
* Fix some stuff
* Fix more stuff
* Add `hasPendingActivity()` to glob
* accident
* Symlinks
* fast-glob e2e tests
* remove
* woops
* Fix relative paths
* Fix absolute
* add test for `onlyFiles`
* Fix invalid surrogate pairs problem
* Rename: `match/matchSync` -> `scan/scanSync` and `matchString` -> `match`
* forgot to close cwd fd
* Update types
* Add stress test
* Port `micromatch` / `glob-match` / `globlin` tests
* fix stale reference arena thing
* stupid bug
* Add builtins to classes code generator and add `Glob.scanIter()`
* all iterables
* generate fixtures, remove from git
* fix test
* Fix
* woops on test
* Fix stuff
licenses
license
`has_pending_activity` to usize
cwd threadSafe fix atomic compile errors
`GlobWalker` own `cwd`
Fix windows path and absolute test
stuff
* Fixes
* Fix stuff
* Use Syscall.close
* Use private symbols for underlying scan functions to preevent misuse
* Update types
* Fix build for zig
* Fix tests
* Fix more tests
* Prevent these tests from GC'ing too much
* Make this benchmark work in Node and Bun
* Fix memory leak
* Add leak test
* Fix windows
* comment about arena allocator use for glob walker
* Make leak test run in separate process
* Iterator api for glob
* GlobWalker.Iterator
* fix leak test
* Remove old impl
* filter functions wip start
* stuff
* wip lockfile use glob
* glob working with lockfile
* revert lockfile changes
* Update bun.lockb
* Manually set to cwd to prevent test failing on linux CI
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* Load `.{m,c}ts{x}` last in node_modules
* feat(console.log): Print className for an object if present (#6508)
* feat(console-log): fix className not printed for objects that are instances of classes
Uses getClassName native method instead of getName
* test(console-log): objects with class names are printed correctly
* test(esbuild): add class name to log message
* Fix failing `which` test (#7258)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* Make test less flaky
* Get it working and add test
* Handle relative paths
* Add comment
* Consolidate + add test
* Bump
* Fix getObjectName
* Update dir_info.zig
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Jibran Kalia <jibran.kalia@gmail.com>
* feat(console-log): fix className not printed for objects that are instances of classes
Uses getClassName native method instead of getName
* test(console-log): objects with class names are printed correctly
* test(esbuild): add class name to log message
* Cleanup error formatting a little
* Add error for using import statement with CommonJS-only features
* Update js_ast.zig
* Further tweaks to formatting, also print error.cause
* Add some snapshot tests for errors
* Make these snapshot tests
* Ignore mimalloc warnings
* Update error message parsing in bundling tests
* Increase timeout on the test
* Update expectBundled.ts
* Update test
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* fix(Bun.serve): return EACCESS when we don't have perms
The error reported to js land when listening fails was always the same,
this adds a second one for EACCESS when we are not the super user.
Fixes: https://github.com/oven-sh/bun/issues/7187
* fix: adjust code to be only ran on linuz
* fix: correct typo
* fix: remove comment since its linux only now
* Stop swallowing errors from create_hash_table during the build
If src/codegen/create_hash_table can't be run due to some reason
(e.g. due to missing Math::BigInt Perl module) the build continues
but fails later, during bindings compilation, because the generated
files are empty.
Fix it by handling the failure to run create_hash_table properly.
Closes#7074
* [autofix.ci] apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* `Response` -> `any`
* Revert previous commit & allow void in ws fetch
* Added type test to check if you can upgrade connection without returning
* [autofix.ci] apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* bounds checks
* do this all the time
cc @paperdave
* use length of string
* ttest
* min
* can't prefix if length isn't at least equal
* substring
* Update pretty_format.zig
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* bin might need to be created after iterating node_modules
* Update bun-install-registry.test.ts
* test this functionality in a few more tests
* fix a test
* another test
* revert
* more test
* Don't allocate new `"require"` and `"resolve"` strings in every CommonJS module
* Use builtinNames more
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-16 15:10:27 -08:00
2494 changed files with 501269 additions and 145040 deletions
Bun is built on macOS, Linux, and Windows. The process is split into the following steps, the first 3 of which are able to run in parallel:
#### 1. `build-deps`
Builds the static libaries in `src/deps` and outputs a directory: `build/bun-deps`.
- on Windows, this runs the script: [`scripts/all-dependencies.ps1`](scripts/all-dependencies.ps1)
- on macOS and Linux, this runs the script: [`scripts/all-dependencies.sh`](scripts/all-dependencies.sh)
#### 2. `build-zig`
Builds the Zig object file: `build/bun-zig.o`. Since `zig build` supports cross-compiling, this step is run on macOS aarch64 since we have observed it to be the fastest.
- on macOS and Linux, this runs the script: [`scripts/build-bun-zig.sh`](scripts/build-bun-zig.sh)
#### 3. `build-cpp`
Builds the C++ object file: `build/bun-cpp-objects.a`.
- on Windows, this runs the script: [`scripts/build-bun-cpp.ps1`](scripts/build-bun-cpp.ps1)
- on macOS and Linux, this runs the script: [`scripts/build-bun-cpp.sh`](scripts/build-bun-cpp.sh)
#### 4. `link` / `build-bun`
After the `build-deps`, `build-zig`, and `build-cpp` steps have completed, this step links the Zig object file and C++ object file into a single binary: `bun-<os>-<arch>.zip`.
- on Windows, this runs the script: [`scripts/buildkite-link-bun.ps1`](scripts/buildkite-link-bun.ps1)
- on macOS and Linux, this runs the script: [`scripts/buildkite-link-bun.sh`](scripts/buildkite-link-bun.sh)
To speed up the build, thare are two options:
-`--fast`: This disables the LTO (link-time optimization) step.
- without `--fast`: This runs the LTO step, which is the default. The binaries that are release to Github are always built with LTO.
### Testing
### FAQ
> How do I add a new CI agent?
> How do I add/modify system dependencies?
> How do I SSH into a CI agent?
### Known issues
These are things that we know about, but haven't fixed or optimized yet.
- There is no `scripts/build-bun-zig.ps1` for Windows.
- The `build-deps` step does not cache in CI, so it re-builds each time (though it does use ccache). It attempts to check the `BUN_DEPS_CACHE_DIR` environment variable, but for some reason it doesn't work.
- Windows and Linux machines sometimes take up to 1-2 minutes to start tests. This is because robobun is listening for when the job is scheduled to provision the VM. Instead, it can start provisioning during the link step, or keep a pool of idle VMs around (but it's unclear how more expensive this is).
- There are a limited number of macOS VMs. This is because they are expensive and manually provisioned, mostly through MacStadium. If wait times are too long we can just provision more, or buy some.
- To prevent idle machines, robobun periodically checks for idle machines and terminates them. Before doing this, it checks to see if the machine is connected as an agent to Buildkite. However, sometimes the machine picks up a job in-between this time, and the job is terminated.
Thank you for submitting a bug report. It helps make Bun better.
If you need help or support using Bun, and are not reporting a bug, please
join our [Discord](https://discord.gg/CXdq2DP29u) server, where you can ask questions in the [`#help`](https://discord.gg/32EtH6p7HN) forum.
Make sure you are running the [latest](https://bun.sh/docs/installation#upgrading) version of Bun.
The bug you are experiencing may already have been fixed.
Please try to include as much information as possible.
- type:input
attributes:
label:What version of Bun is running?
description:Copy the output of `bun --revision`
- type:input
attributes:
label:What platform is your computer?
description:|
For MacOS and Linux: copy the output of `uname -mprs`
For Windows: copy the output of `"$([Environment]::OSVersion | ForEach-Object VersionString) $(if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" })"` in the PowerShell console
- type:textarea
attributes:
label:What steps can reproduce the bug?
description:Explain the bug and provide a code snippet that can reproduce it.
validations:
required:true
- type:textarea
attributes:
label:What is the expected behavior?
description:If possible, please provide text instead of a screenshot.
- type:textarea
attributes:
label:What do you see instead?
description:If possible, please provide text instead of a screenshot.
- type:textarea
attributes:
label:Additional information
description:Is there anything else you think we should know?
**Thank you so much** for submitting a crash report. You're helping us make Bun more reliable for everyone!
- type:textarea
id:code
attributes:
label:How can we reproduce the crash?
description:Please provide a [minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example) using a GitHub repository, [Replit](https://replit.com/@replit/Bun) or [CodeSandbox](https://codesandbox.io/templates/bun)
- type:textarea
id:logs
attributes:
label:Relevant log output
description:Please copy and paste any relevant log output. This will be
automatically formatted into code, so no need for backticks.
**Thank you so much** for submitting a crash report. You're helping us make Bun more reliable for everyone!
- type:textarea
id:repro
attributes:
label:How can we reproduce the crash?
description:Please provide a [minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example) using a GitHub repository, [Replit](https://replit.com/@replit/Bun) or [CodeSandbox](https://codesandbox.io/templates/bun)
- type:textarea
id:logs
attributes:
label:Relevant log output
description:Please copy and paste any relevant log output. This will be
automatically formatted into code, so no need for backticks.
@${{ github.event.issue.user.login }}, the latest version of Bun is v${{ steps.add-labels.outputs.latest }}, but this crash was reported on Bun v${{ steps.add-labels.outputs.oudated }}.
Are you able to reproduce this crash on the latest version of Bun?
```sh
bun upgrade
```
- name:Comment needs repro
if:github.event.label.name == 'needs repro'
uses:actions-cool/issues-helper@v3
with:
actions:"create-comment"
token:${{ secrets.GITHUB_TOKEN }}
issue-number:${{ github.event.issue.number }}
body:|
Hello @${{ github.event.issue.user.login }}. Please provide a [minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example) using a GitHub repository, [Replit](https://replit.com/@replit/Bun), or [CodeSandbox](https://codesandbox.io/templates/bun). Issues marked with `needs repro` will be closed if they have no activity within 3 days.
Configuring a development environment for Bun can take 10-30 minutes depending on your internet connection and computer speed. You will need ~10GB of free disk space for the repository and build artifacts.
> **Important:** All contributions need test coverage. If you are adding a new feature, please add a test. If you are fixing a bug, please add a test that fails before your fix and passes after your fix.
If you are using Windows, please refer to [this guide](/docs/project/building-windows)
## Bun's codebase
{% details summary="For Ubuntu users" %}
TL;DR: Ubuntu 22.04 is suggested.
Bun currently requires `glibc >=2.32` in development which means if you're on Ubuntu 20.04 (glibc == 2.31), you may likely meet `error: undefined symbol: __libc_single_threaded `. You need to take extra configurations. Also, according to this [issue](https://github.com/llvm/llvm-project/issues/97314), LLVM 16 is no longer maintained on Ubuntu 24.04 (noble). And instead, you might want `brew` to install LLVM 16 for your Ubuntu 24.04.
{% /details %}
Bun is written mostly in Zig, but WebKit & JavaScriptCore (the JavaScript engine) is written in C++.
## Install Dependencies
Today (February 2023), Bun's codebase has five distinct parts:
Using your system's package manager, install Bun's dependencies:
- JavaScript, JSX, & TypeScript transpiler, module resolver, and related code
The JavaScript transpiler & module resolver is mostly independent from the runtime. It predates the runtime and is entirely in Zig. The JavaScript parser is mostly in [`src/js_parser.zig`](src/js_parser.zig). The JavaScript AST data structures are mostly in [`src/js_ast.zig`](src/js_ast.zig). The JavaScript lexer is in [`src/js_lexer.zig`](src/js_lexer.zig). A lot of this code started as a port of esbuild's equivalent code from Go to Zig, but has had many small changes since then.
1. Do your best to avoid dynamically allocating memory.
2. If we need to allocate memory, carefully consider the owner of that memory. If it's a JavaScript object, it will need a finalizer. If it's in Zig, it will need to be freed either via an arena or manually.
3. Prefer arenas over manual memory management. Manually freeing memory is leak & crash prone.
4. If the memory needs to be accessed across threads, use `bun.default_allocator`. Mimalloc threadlocal heaps are not safe to free across threads.
{% /codetabs %}
The JavaScript transpiler has special-handling for memory management. The parser allocates into a single arena and the memory is recycled after each parse.
> **Note**: The Zig compiler is automatically installed and updated by the build scripts. Manual installation is not required.
## JavaScript runtime
Before starting, you will need to already have a release build of Bun installed, as we use our bundler to transpile and minify our code, as well as for code generation scripts.
Most of Bun's JavaScript runtime code lives in [`src/bun.js`](src/bun.js).
{% codetabs %}
### Calling C++ from Zig & Zig from C++
```bash#Native
$ curl -fsSL https://bun.sh/install | bash
```
TODO: document this (see [`bindings.zig`](src/bun.js/bindings/bindings.zig) and [`bindings.cpp`](src/bun.js/bindings/bindings.cpp) for now)
```bash#npm
$ npm install -g bun
```
### Adding a new JavaScript class
```bash#Homebrew
$ brew tap oven-sh/bun
$ brew install bun
```
1. Add a new file in [`src/bun.js/*.classes.ts`](src/bun.js) to define the instance and static methods for the class.
2. Add a new file in [`src/bun.js/**/*.zig`](src/bun.js) and expose the struct in [`src/bun.js/generated_classes_list.zig`](src/bun.js/generated_classes_list.zig)
3. Run `make codegen`
{% /codetabs %}
Copy from examples like `Subprocess` or `Response`.
## Install LLVM
### ESM Modules and Builtins JS
Bun requires LLVM 16 (`clang` is part of LLVM). This version requirement is to match WebKit (precompiled), as mismatching versions will cause memory allocation failures at runtime. In most cases, you can install LLVM through your system package manager:
Bun implements ESM modules in a mix of native code and JavaScript.
{% codetabs %}
Several Node.js modules are implemented in JavaScript and loosely based on browserify polyfills.
```bash#macOS (Homebrew)
$ brew install llvm@16
```
Builtin modules in Bun are located in [`src/js`](src/js/). These files are transpiled and support a JavaScriptCore-only syntax for internal slots, which is explained further in [`src/js/README.md`](src/js/README.md).
```bash#Ubuntu/Debian
$ # LLVM has an automatic installation script that is compatible with all versions of Ubuntu
TODO: fill this out (for now, use `JSC.Strong` in most cases)
{% /codetabs %}
### Strings
If none of the above solutions apply, you will have to install it [manually](https://github.com/llvm/llvm-project/releases/tag/llvmorg-16.0.6).
TODO: fill this out (for now, use `JSValue.toSlice()` in most cases)
Make sure Clang/LLVM 16 is in your path:
#### JavaScriptCore C API
```bash
$ which clang-16
```
Do not copy from examples leveraging the JavaScriptCore C API. Please do not use this in new code. We will not accept PRs that add new code that uses the JavaScriptCore C API.
If not, run this to manually add it:
## Testing
{% codetabs %}
See [`test/README.md`](test/README.md) for information on how to run tests.
```bash#macOS (Homebrew)
# use fish_add_path if you're using fish
# use path+="$(brew --prefix llvm@16)/bin" if you are using zsh
> ⚠️ Ubuntu distributions (<= 20.04) may require installation of the C++ standard library independently. See the [troubleshooting section](#span-file-not-found-on-ubuntu) for more information.
## Building Bun
After cloning the repository, run the following command to run the first build. This may take a while as it will clone submodules and build dependencies.
```bash
$ bun setup
```
The binary will be located at `./build/bun-debug`. It is recommended to add this to your `$PATH`. To verify the build worked, let's print the version number on the development build of Bun.
```bash
$ build/bun-debug --version
x.y.z_debug
```
To rebuild, you can invoke `bun run build`
```bash
$ bun run build
```
These two scripts, `setup` and `build`, are aliases to do roughly the following:
Advanced users can pass CMake flags to customize the build.
## VSCode
VSCode is the recommended IDE for working on Bun, as it has been configured. Once opening, you can run `Extensions: Show Recommended Extensions` to install the recommended extensions for Zig and C++. ZLS is automatically configured.
If you use a different editor, make sure that you tell ZLS to use the automatically installed Zig compiler, which is located at `./.cache/zig/zig.exe`. The filename is `zig.exe` so that it works as expected on Windows, but it still works on macOS/Linux (it just has a surprising file extension).
We recommend adding `./build` to your `$PATH` so that you can run `bun-debug` in your terminal:
```sh
$ bun-debug
```
## Code generation scripts
Several code generation scripts are used during Bun's build process. These are run automatically when changes are made to certain files.
In particular, these are:
- `./src/codegen/generate-jssink.ts` -- Generates `build/codegen/JSSink.cpp`, `build/codegen/JSSink.h` which implement various classes for interfacing with `ReadableStream`. This is internally how `FileSink`, `ArrayBufferSink`, `"type": "direct"` streams and other code related to streams works.
- `./src/codegen/generate-classes.ts` -- Generates `build/codegen/ZigGeneratedClasses*`, which generates Zig & C++ bindings for JavaScriptCore classes implemented in Zig. In `**/*.classes.ts` files, we define the interfaces for various classes, methods, prototypes, getters/setters etc which the code generator reads to generate boilerplate code implementing the JavaScript objects in C++ and wiring them up to Zig
- `./src/codegen/bundle-modules.ts` -- Bundles built-in modules like `node:fs`, `bun:ffi` into files we can include in the final binary. In development, these can be reloaded without rebuilding Zig (you still need to run `bun run build`, but it re-reads the transpiled files from disk afterwards). In release builds, these are embedded into the binary.
- `./src/codegen/bundle-functions.ts` -- Bundles globally-accessible functions implemented in JavaScript/TypeScript like `ReadableStream`, `WritableStream`, and a handful more. These are used similarly to the builtin modules, but the output more closely aligns with what WebKit/Safari does for Safari's built-in functions so that we can copy-paste the implementations from WebKit as a starting point.
## Modifying ESM modules
Certain modules like `node:fs`, `node:stream`, `bun:sqlite`, and `ws` are implemented in JavaScript. These live in `src/js/{node,bun,thirdparty}` files and are pre-bundled using Bun.
## Release build
To compile a release build of Bun, run:
```bash
$ bun run build:release
```
The binary will be located at `./build-release/bun` and `./build-release/bun-profile`.
### Download release build from pull requests
To save you time spent building a release build locally, we provide a way to run release builds from pull requests. This is useful for manully testing changes in a release build before they are merged.
To run a release build from a pull request, you can use the `bun-pr` npm package:
This will download the release build from the pull request and add it to `$PATH` as `bun-${pr-number}`. You can then run the build with `bun-${pr-number}`.
```sh
bun-1234566 --version
```
This works by downloading the release build from the GitHub Actions artifacts on the linked pull request. You may need the `gh` CLI installed to authenticate with GitHub.
## Valgrind
On Linux, valgrind can help find memory issues.
Keep in mind:
- JavaScriptCore doesn't support valgrind. It will report spurious errors.
- Valgrind is slow
- Mimalloc will sometimes cause spurious errors when debug build is enabled
You'll need a very recent version of Valgrind due to DWARF 5 debug symbols. You may need to manually compile Valgrind instead of using it from your Linux package manager.
`--fair-sched=try` is necessary if running multithreaded code in Bun (such as the bundler). Otherwise it will hang.
**TODO**: This is out of date. TLDR is pass `-DUSE_DEBUG_JSC=1` or `-DWEBKIT_DIR=...` to CMake. it will probably need more fiddling. ask @paperdave if you need this.
{% /callout %}
WebKit is not cloned by default (to save time and disk space). To clone and build WebKit locally, run:
```bash
# once you run this, `make submodule` can be used to automatically
# JSC debug build does not work perfectly with Bun yet, this is actively being
# worked on and will eventually become the default.
$ make jsc-build-linux-compile-debug cpp
$ make jsc-build-mac-compile-debug cpp
```
Note that the WebKit folder, including build artifacts, is 8GB+ in size.
If you are using a JSC debug build and using VScode, make sure to run the `C/C++: Select a Configuration` command to configure intellisense to find the debug headers.
## Troubleshooting
### 'span' file not found on Ubuntu
> ⚠️ Please note that the instructions below are specific to issues occurring on Ubuntu. It is unlikely that the same issues will occur on other Linux distributions.
The Clang compiler typically uses the `libstdc++` C++ standard library by default. `libstdc++` is the default C++ Standard Library implementation provided by the GNU Compiler Collection (GCC). While Clang may link against the `libc++` library, this requires explicitly providing the `-stdlib` flag when running Clang.
Bun relies on C++20 features like `std::span`, which are not available in GCC versions lower than 11. GCC 10 doesn't have all of the C++20 features implemented. As a result, running `make setup` may fail with the following error:
```
fatal error: 'span' file not found
#include <span>
^~~~~~
```
The issue may manifest when initially running `bun setup` as Clang being unable to compile a simple program:
```
The C++ compiler
"/usr/bin/clang++-16"
is not able to compile a simple test program.
```
To fix the error, we need to update the GCC version to 11. To do this, we'll need to check if the latest version is available in the distribution's official repositories or use a third-party repository that provides GCC 11 packages. Here are general steps:
```bash
$ sudo apt update
$ sudo apt install gcc-11 g++-11
# If the above command fails with `Unable to locate package gcc-11` we need
If you see an error on macOS when compiling `libarchive`, run:
```bash
$ brew install pkg-config
```
### macOS `library not found for -lSystem`
If you see this error when compiling, run:
```bash
$ xcode-select --install
```
## Cannot find `libatomic.a`
Bun defaults to linking `libatomic` statically, as not all systems have it. If you are building on a distro that does not have a static libatomic available, you can run the following command to enable dynamic linking:
```bash
$ bun setup -DUSE_STATIC_LIBATOMIC=OFF
```
The built version of Bun may not work on other systems if compiled this way.
## ccache conflicts with building TinyCC on macOS
If you run into issues with `ccache` when building TinyCC, try reinstalling ccache
Bun statically links JavaScriptCore (and WebKit) which is LGPL-2 licensed. WebCore files from WebKit are also licensed under LGPL2. Per LGPL2:
> (1) If you statically link against an LGPL’d library, you must also provide your application in an object (not necessarily source) format, so that a user has the opportunity to modify the library and relink the application.
You can find the patched version of WebKit used by Bun here: <https://github.com/oven-sh/webkit>. If you would like to relink Bun with changes:
-`git submodule update --init --recursive`
-`make jsc`
-`zig build`
This compiles JavaScriptCore, compiles Bun’s `.cpp` bindings for JavaScriptCore (which are the object files using JavaScriptCore) and outputs a new `bun` binary with your changes.
| [`libuv`](https://github.com/libuv/libuv) (on Windows) | MIT |
| [`libdeflate`](https://github.com/ebiggers/libdeflate) | MIT |
| A fork of [`uWebsockets`](https://github.com/jarred-sumner/uwebsockets) | Apache 2.0 licensed |
| Parts of [Tigerbeetle's IO code](https://github.com/tigerbeetle/tigerbeetle/blob/532c8b70b9142c17e07737ab6d3da68d7500cbca/src/io/windows.zig#L1) | Apache 2.0 licensed |
## Polyfills
For compatibility reasons, the following packages are embedded into Bun's binary and injected if imported.
| Package | License |
|---------|---------|
| [`assert`](https://npmjs.com/package/assert) | MIT |
| [`browserify-zlib`](https://npmjs.com/package/browserify-zlib) | MIT |
| [`buffer`](https://npmjs.com/package/buffer) | MIT |
| [`constants-browserify`](https://npmjs.com/package/constants-browserify) | MIT |
| [`crypto-browserify`](https://npmjs.com/package/crypto-browserify) | MIT |
| [`domain-browser`](https://npmjs.com/package/domain-browser) | MIT |
| [`events`](https://npmjs.com/package/events) | MIT |
| [`https-browserify`](https://npmjs.com/package/https-browserify) | MIT |
| [`os-browserify`](https://npmjs.com/package/os-browserify) | MIT |
| [`path-browserify`](https://npmjs.com/package/path-browserify) | MIT |
| [`process`](https://npmjs.com/package/process) | MIT |
| [`punycode`](https://npmjs.com/package/punycode) | MIT |
| [`querystring-es3`](https://npmjs.com/package/querystring-es3) | MIT |
| [`stream-browserify`](https://npmjs.com/package/stream-browserify) | MIT |
| [`stream-http`](https://npmjs.com/package/stream-http) | MIT |
| [`string_decoder`](https://npmjs.com/package/string_decoder) | MIT |
| [`timers-browserify`](https://npmjs.com/package/timers-browserify) | MIT |
| [`tty-browserify`](https://npmjs.com/package/tty-browserify) | MIT |
| [`url`](https://npmjs.com/package/url) | MIT |
| [`util`](https://npmjs.com/package/util) | MIT |
| [`vm-browserify`](https://npmjs.com/package/vm-browserify) | MIT |
## Additional credits
- Bun's JS transpiler, CSS lexer, and Node.js module resolver source code is a Zig port of [@evanw](https://github.com/evanw)’s [esbuild](https://github.com/evanw/esbuild) project.
- Credit to [@kipply](https://github.com/kipply) for the name "Bun"!
> **Bun is under active development.** Use it to speed up your development workflows or run simpler production code in resource-constrained environments like serverless functions. We're working on more complete Node.js compatibility and integration with existing frameworks. Join the [Discord](https://bun.sh/discord) and watch the [GitHub repository](https://github.com/oven-sh/bun) to keep tabs on future releases.
> **Bun is under active development.** Use it to speed up your development workflows or run simpler production code in resource-constrained environments like serverless functions. We're working on more complete Node.js compatibility and integration with existing frameworks. Join the [Discord](https://bun.sh/discord) and watch the [GitHub repository](https://github.com/oven-sh/bun) to keep tabs on future releases.
Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a single executable called `bun`.
Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a single executable called `bun`.
At its core is the _Bun runtime_, a fast JavaScript runtime designed as a drop-in replacement for Node.js. It's written in Zig and powered by JavaScriptCore under the hood, dramatically reducing startup times and memory usage.
@@ -34,27 +34,28 @@ At its core is the _Bun runtime_, a fast JavaScript runtime designed as a drop-i
bun run index.tsx # TS and JSX supported out-of-the-box
```
The `bun` command-line tool also implements a test runner, script runner, and Node.js-compatible package manager. Instead of 1,000 node_modules for development, you only need `bun`. Bun's built-in tools are significantly faster than existing options and usable in existing Node.js projects with little to no changes.
The `bun` command-line tool also implements a test runner, script runner, and Node.js-compatible package manager. Instead of 1,000 node_modules for development, you only need `bun`. Bun's built-in tools are significantly faster than existing options and usable in existing Node.js projects with little to no changes.
```bash
bun test# run tests
bun run start # run the `start` script in `package.json`
bun install <pkg># install a package
bun install <pkg> # install a package
bunx cowsay 'Hello, world!'# execute a package
```
## Install
Bun supports Linux (x64 & arm64) and macOS (x64 & Apple Silicon).
Bun supports Linux (x64 & arm64), macOS (x64 & Apple Silicon) and Windows (x64).
> **Linux users** — Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1.
>
> **Windows users** — Bun does not currently provide a native Windows build. We're working on this; progress can be tracked at [this issue](https://github.com/oven-sh/bun/issues/43). In the meantime, use one of the installation methods below for Windows Subsystem for Linux.
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.