* 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>
* `zig fmt`
* Support using macros in builtins
* Make fetch work a little better in macros
* Delete a bunch of code
* Update macro-test.test.ts
* Update macro-test.test.ts
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* Implement `expect.unreachable`
* UIse expect.unreachable() in some tests
* Use more unreachable
* More unreachable
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* fix(install): fix the case that package name contains tilde.
Close: #7045
* add tests
* emm, let me know why test failed
* overwrite registry config
* check more chars
* remove $
This causes keep-alive to be disabled for HTTP status codes that do not support bodies, leading to many HTTP client hangs.
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* Use debug mode by default
* Enable build with assertions enabled
* Update cli.zig
* Update bun-linux-build.yml
* Fixes
* Fix `ASSERT_ENABLED`
* try this
* Update Dockerfile
* mimalloc debug
* Update CMakeLists.txt
* `Bun.deepMatch` - fix assertion failures
cc @dylan-conway, looks like we need to use `putDirectMayBeIndex` and check for `isCell` more carefully.
* Object.create support in code generator and callbacks wrapper
* Remove unused file
* zig upgrade
* zls
* Fix various errors
* Support `BuiltinAccessor` in create_hash_table script
* Fix assertion failure in `process.mainModule`
* Fix assertion failure in `onerror`
* Fix assertion failure when creating a Worker
* Fix asssertion failure when loading lots of files in bun test
* Fix assertion failure when termating a `Worker`
* Add helper for converting BunString to a WTFString
* Fix assertion failure in notifyNeedTermination
* Add more debug logs in `bun test`
* Fix compiler warning in usockets
* Fix assertion failure with `Worker` termination (another)
* Fix assertion failure in `coerceToInt64`
* Fix assertion failure in `BroadcastChannel`
* Fix assertion failure in `Headers.prototype.getAll`
* Fixes#7067
* Add heap analyzer label for CommonJS modules
* Fix assertion failure in module.require && module.require.resolve
* Remove unused code
* Fix assertion failure in debugger
* Fix crash in debugger
* Fix assertion failures in bun:sqlite
* Bump zig
* Bump WebKit
* Fix assertion failure in JSPromise::reject && JSInternalPromise::reject
* Fix assertion failure in ReadableStream::cancel
* Fix assertion failure in AsyncContextFrame::create
* Fix assertion failure in bun:sqlite
* Fix assertion failure in mocks
* Fix assertion failure in ServerWebSocket.close
* Fix assertion failure in N-API with subclasses
* [napi] Make promises cheaper
* undo
* Don't check for exceptions in ObjectInitializationScope
* Add separate entry point for test runner that doesn't generate code
* Don't deref builtin code
* Fix preload test
* Fix assertion failure in memoryUsage()
* Fix preload test, part 2
* Ensure that the env map for a Worker is empty after it is used
* The pointer for the Arena allocator used in parsing should not change
* Terminate thread on exit
* Start to implement scriptExecutionStatus
* Update worker.test.ts
* Fix Dirent.name setter
* Update settings.json
* Fix assertion failure in node:http
* Use correct value for `JSFinalObject::maxInlineCapacity`
* JSFinalObject::maxInlineCapacity x2
* Don't strip when assertions are enabled
* Make `m_wasTerminated` atomic
* Preserve directives in the transpiler
cc @ctjlewis
* Workaround assertion failure in ServerWebSocket.sendBinary and ServerWebSocket.sendText
* windows
* Buffer lockfile serialization in-memory
* PR feedback
* PR feedback
* PR feedback
* Windows
* quotes
* Update CMakeLists.txt
* Update bun-linux-build.yml
* Update bun-linux-build.yml
* Move this code to BunString.cpp
* Update BunString.cpp
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
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
* Update CI/CD guide
The guide at https://bun.sh/guides/runtime/cicd shows an outdated example for specifying a version of Bun.
It currently shows "version" and it should be updated to "bun-version".
* Add more examples in CI/CD guide
- move dependencies installation to the front, as the next steps
depend on them
- add missing xz-utils, which, libicu-devel to the dependencies
Closes#7076Closes#7077
* Fix fetch response skipping body if no content-length (#6932)
* Fix timeout on status 1xx/204/304 without content-length, tests changes
* Fix test that was wrong
* fix fetch response without content-length not disabling keep-alive
---------
Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
* use different buf for group and manifest versions
* tests
* tests for installs that should fail
* allow `<=<prerelease-version`
* `Bun.semver.satisfies`
* one
* stringify
* symbol tests
* deinit
* arena
* more tests
* fix test
* version always on the left
* `Bun.semver.order`
* handle more edge cases, more tests
* whitespace
* more
* fix: correctly prepend system path to relative urls on `pathToFileURL`
The `pathToFileURL` was not handling the case that when a relative link is passed,
it should convert it to a absolute url and prepend the top_folder,
or otherwise described, resolve the path before creating the url.
This does that by calling into buns Path api and using its `resolve` function.
Theres the detail that i used preprocessor directives to determine whether
we are on windows because there does not seam to be a easy way to get that
at runtime in the `BunObject.cpp` file.
Fixes: https://github.com/oven-sh/bun/issues/6456
* fix: add issue id to test name
* fix: implement changes requested in review
* style: fix styling
* Update src/bun.js/bindings/BunObject.cpp
* Update src/bun.js/bindings/BunObject.cpp
* Update src/bun.js/bindings/BunObject.cpp
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* Update to latest SIMDUTF
* Fix issue with `Headers.toJSON` having an incorrect size set with set-cookie header
* [node:http] Fix `undefined` when multiple Set-Cookie headers are sent
* Count UTF8 byteLength for headers
This is not necessary, just being cautious.
* Update http-hello.node.mjs
* Be 100% sure the test isn't caching anything
* move this up
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* Fix the linux aarch64 workflow.
* sanity check
* do not set march to native
* fix windows compile error
* enable verbose
* fix baseline builds
* fix windows build canary flags
* use a real windows runner
* w
* fix(build): add option and auto detect for arch linux
This adds a option and a automatic routine for decting arch linux,
where the path for libatomic is a bit special.
* fix: don't statically link if not needed
* Fix memory leak in require() and add test
* Mark fixtures as generated code
* Add optimization for large files
* Fix small memory leak
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* `order` and `satisfy` prerelease numbers
* remove sorter
* use existing package for peer dep if possible
* fix test, remove loop
* count workspace versions, compare each part of prerelease
* other peer dependencies
* use existing packages if possible
* don't install peer more than once
* fix update tests
* fix fetch
* oops
* revert
* fix checkServerIdentity
* check dns len
* use same checks on wsclient and fetch, fix tests
* more tests and more fixes
* fix node-http flask test
* orelse
* fix requestCert
* more fixes, but no data receiving
* fix pause on connect behavior on TLS
* WS Client + rejectUnauthorized progress
* move test to the right place
* more test
* oops
* oops 2
* fmt
* cleanup
* WIP: handle handshake properly on uWS
* handle rejectUnauthorized in uWS
* fmt
* duplicated test
* fix leak
* add rejectUnauthorized option in WS types
* fix merge
* fix merge2
* Fix for seg faults when using macros
* Update src/js_ast.zig to reflect review suggestions
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* add test for checking non-zero exitcodes under macros. regression, issue 3830
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* feat(console): add printer for mapiterator
MapIterator was not supported in printing, libraries like discordjs make big use of maps and
so i think supporting them would be a good idea.
* fix: snake case var
* fix: add tests for log and add setiterator printer
* Updated Dependencies Script
* demo
* fix submodule hell!!!
* lol
* attmept 2
* install nasm in ci
* setup sh 1
* yeah
* better zlib building
* codegen stuff
* attempt 2 at bun codegen ci
* o
* deps improvements
* generaet part of compile-cpp-only.ps1
* restore these
* good enough for Unix
* remove libuv submodule lol
* pass over docs
* Prepare for windows event loop
* More progress
* Update libuv.zig
* wip
* Make compiling each dependency a shell script
* Bump mimalloc
* Add the build scripts
* Update settings.json
* Fix a bunch of compiler warnings
* Remove more warnings
* more warnings
* cmake works
* Update JSSQLStatement.h
* put it in the zig file
* Fix usockets warnings
* Fixup
* Fix one of the compiler errors
* chunk
* draw the rest of the owl
* theres more
* Rename Process -> BunProcess
Works around a Windows issue
* Add musl polyfill for memmem on Windows
* More
* 12 mb
* Fix getenvZ
* fix variosu issues
* Add fast-ish path for bun install on Windows
* Update windows.zig
* Update windows.zig
* Fix build issue
* it works
* hmmm
* Rename file
* Fixups
* Update wtf-bindings.cpp
* Update src/bun.js/bindings/headers-handwritten.h
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
* further!
* more
* Update .gitignore
* hm
* quite a lot of fixes
* Update CMakeLists.txt
* zig fmt
* Many more things are starting to work.
* reb
* regenaret
* Update JSSink.h
* fixup
* fetch works
* Bun.serve() and much of the event loop works now
* Make require() work
* bun install progress
* more things work
* use less std.os
* Fixes
* small fixes
* Bump
* Bummp
* Undo that change
* We have to bump the version of Debian because libarchive has a higher minimum requirement
* ok
* some clenaup
* windows
* Update bun.zig
* fixup
* avoid duplicate symbols
* avoid undefined symbols
* bump
* Remove issue template for install
It's not used, and use the bug issue instead.
* Add types for cp and cpSync
* Add types for watchFile and unwatchFile
* Add bun-types to 'bun fmt' script
* Update nodejs compat docs cp/cpSync/watchFile/unwatchFile (#4525)
* feat(fetch) rejectUnauthorized and checkServerIdentity (#4514)
* enable root certs on fetch
* rebase
* fix lookup
* some fixes and improvements
* fmt
* more fixes
* more fixes
* check detached onHandshake
* fix promise case
* fix cert non-Native
* add fetch tls tests
* more one test
* churn
* Update feature_flags.zig
* Update response.zig
* Revert "avoid undefined symbols"
This reverts commit ca835b726f.
* Revert "avoid duplicate symbols"
This reverts commit 4ac6ca8700.
* Update feature_flags.zig
* Set permissions
* more
* Update mimalloc
* Fix sqlite test failures
* Fix some test failures
* Make sure we remove libusockets is removed
* hm
* [dave]: fix webcrypto crash
* bump
* Update index.ts
* windows zig compiles
* cmake on mac works
* progress
* yay
* bun run build
* fix
* ok
* oops
* asdfasfdafdsafda
* fghjkl
* git ignore
* wow
* Process -> BunProcess
* hmm
* blah
* finalize merge
* now it only has linker errors on mac
* sdfadsf
* g
* getting farther
* sxdcvbnmk,
* adfhjskfjdhkas
* a
* fgh
* update build dot zig
* asdfg
* theoretical -DCANARY flag we can use
* asdf
* cool
* okay
* colorterm
* New build workflow
* Fix script
* Use sudo
* More sudo
* Tweak dependencies
* Another sudo attempt
* Tweak script
* 16.0 -> 16
* Tweak script
* Tweak script
* Tweak script
* Tweak script
* Tweak script
* bun install
* ssh into github actions
* add more to ssh
* Fix postinstal
* Skip llvm
* New dockerfile
* Build
* More changes to Dockerfile
* chaos chaos chaos
* okay
* a
* more cmake nonsense
* add unified sources code (does not work)
* stuff
* prepare for CI builds
* ok
* yay
* yeah
* make this more stable simply by trying again if it fails, 5 times, then lose. it fixes the stability issue i was running into L O L
* messing with ci
* x
* a
* clean dependencies before build
* oops
* this is not going to work but its closer
* not gonna work either
* a
* a
* did i do it
* a
* a
* work around weird fs+Bun.build issues
* properly pass debug flag correctly
* idk im sorry
* lose
* maybe
* run the tests please
* a
* fix zlib script
* a
* hi
* prevent stupid ci issue
* i totally didnt leave in a syntax error on cmakelists
* a
* lol
* relax
* 😭
* a
* SO SILLY
* 😡 one line mistake
* one character diff
* fix linking symbols missing
* work on dependency scripts
* does this work now?
* fix mac build
* a
* bump!
* woops
* add macos baseline build
* .
* fix sqlite and also enable $assert/$debug support in builtin functions
* okay
* oops
* zig upgrade lol
* Merge
* Fix spawn test issue
* Set a timeout
* yeah
* etc
* mi
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
Co-authored-by: Birk Skyum <74932975+birkskyum@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
* fix: emit close on stdin stream end
We where not emitting the `close` event when done reading stdin data.
It took me way too long to find this but i kept searching in zig/cpp code of the stream implementations...
Fixes: https://github.com/oven-sh/bun/issues/6713
* fix: don't emit close twice
* Copy Node.js test for async-local-storage thenables
* Fix flaky test
* Make expect(fn).toThrow() more reliable
* Fix setImmediate order
* Support restoring mocked modules with spyOn
* Fix vm test
* Fix more tests
* alright
* Upgrade WebKit
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
while trying to get [`node-usb`](https://github.com/node-usb/node-usb) running with bun, it always failed because close() is only allowed when there are no open references.
7e0182df8c/src/node_usb.h (L39-L41)
```c++
inline void ref(){ refs_ = Ref();}
inline void unref(){ refs_ = Unref();}
inline bool canClose(){return refs_ == 0;}
```
`Ref()` and `Unref()` are both called once, with node.js resulting in `refs_ == 0` (which is expected), but with bun `refs_ == 1`.
I've made this small script to reproduce the bug:
https://github.com/alangecker/bun-ref-bug/blob/main/binding.cc
```
run with bun 1.0.6:
- refcount: 2 (expected: 1)
run with node 20.8.1:
- refcount: 1 (expected: 1)
```
during a long debugging journey I found out, that buns `NapiRef::ref()` is also just called once (as expected), but within `napi_wrap()` the `NapiRef` gets initialized already with the refCount set to 1
378385ba60/src/bun.js/bindings/napi.cpp (L669)
```c++
extern "C" napi_status napi_wrap(napi_env env,
napi_value js_object,
void* native_object,
napi_finalize finalize_cb,
void* finalize_hint,
napi_ref* result)
{
// [...]
auto* ref = new NapiRef(globalObject, 1);
// [...]
}
```
After changing it to `new NapiRef(globalObject, 0)` it got the expected behavior / same as with node.js and node-usb works.
as far as I understand it, a `NapiRef`` with refCount=0 should then be weak instead of strong, which is why I have changed this too.
* Update quickstart.md - removed the part for editing `compilerOptions` in `tsconfig.json`
The line is already added to `compilerOptions` in `tsconfig.json` so there is no need to edit the file.
"types": [
"bun-types" // add Bun global
]
This was already added when the project initialized it seems.
* Typescript section
---------
Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
* fix findBestMatch so it finds the best match and not the first match
* update complex-workspaces to include lines-and-columns ^1.1.6
* PR feedback
* PR feedback
* This test doesn't reproduce the original issue
* Support pre release versions the same way
* Add a test that reproduces the original issue
* Sort the list of package versions before serializing to disk
* Remove test that didnt reproduce it
* Fix the count
* Fix 0 and 1 and sorting order
* Fix assertions and ordering
---------
Co-authored-by: Dylan Greene <dgreene@medallia.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* fix findBestMatch so it finds the best match and not the first match
* update complex-workspaces to include lines-and-columns ^1.1.6
* PR feedback
* PR feedback
* Fix missing function names in Bun.inspect
* Fix failing tests
* Handle @@toStringTag
* Update bindings.cpp
* Revert breaking changes to snapshots until a minor version
* Fix test
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* fix: support custom file type in Bun.file
In the docs it seamed to suggest this is something supported,
it seamed to be only supported in JSDOMFiles or blob.
This Adds the 2 properties `type` and `lastModified` to be supported on `Bun.file`
Fixes: https://github.com/oven-sh/bun/issues/6507
* fix: implement changes requested in review
Add changes requested in the review and add a test for a non standard
mimetype
* fix(serve): When IPv6 configuration is incorrect, attempt to bind to IPv4 address under the same hostname.
Close: #5315
* fix review
* fix review again
---------
Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
In this example there is no server variable in the context, and here it makes more sense to use ws.publish. It is explained below that once the serve is done, the server.publish can be used.
* dfghj
* Handle messages that did not finish
* tidy
* ok
* a
* Merge remote-tracking branch 'origin/main' into dave/ipc-fixes
* test failures
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* fix-subprocess-argument-missing
* fix-tests
* nitpick, these should === not just be undefined
---------
Co-authored-by: dave caruso <me@paperdave.net>
* fix pg hang on end + hanging on query
* remove dummy function
* fix node-stream
* add test
* fix test
* return error in test
* fix test use once instead of on
* fix OOM
* generated
* 💅
* 💅
* Docs : Added instructions to run bun apps in daemon (PM2) to address issue #4734
Added instructions to set bun as pm2 interpreter to extend same functionality as node.js apps.
* Add pm2 guide
* Add pm2 file
---------
Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
* work so far
* stuff
* a
* basics work
* stuff
* yoo
* build lockfile
* correct
* f
* a
* install fixture havent tested
* i made it worse
* lol
* be more reasonable
* make the test easier to pass because bun install doesn't handle obscure lockfile edge cases :/
* a
* works now
* ok
* a
* a
* cool
* nah
* fix stuff
* l
* a
* idfk
* LAME
* prettier errors
* does this fix tests?
* Add more safety checks to Integrity
* Add another check
* More careful lifetime handling
* Fix linux debugger issue
* a
* tmp dir and snapshot test
---------
Co-authored-by: Jarred SUmner <jarred@jarredsumner.com>
The exit code support is between 0-255 and not only in the signed positive range
(0-127).
Node.js does not seam to throw on a bigger integer and just wraps around,
but throwing a error is a good approach and makes the behaviour more defined.
This allows the range to be 0-255
Fixes: https://github.com/oven-sh/bun/issues/6284
Returning undefined simply falls through to the next plugin, or to the default loader.
This is defined by esbuild, and supported by Bun, but the types don't reflect it properly.
* Use singular nouns when appropriate on install messages
* Fix one more pluralization
* Fix bun-add tests for "1 package installed"
* Fix bun install/remove/update tests for "1 package installed"
* releases before prereleases
* handle different repo hosts
* remove log
* Update bun-install.test.ts
* test for `bun add`
* gitlab test
* use comptime hash map, another test case
* don't need length
* bump timeout, use tld
* infer git dependencies for https and ssh
* fix bunx command for github package
* refactor fmt package to use it when the path is seted
* use labeled block to assign const instead of use 'undefined'
In the case of creating a Request with the parameters `(Request, object)`,
there was a bug that method and headers are set from the default created by
the init rather then the already present value from the request param.
This is because for a to me unknown reason the order in which the parameters
are processed is reversed.
This fixes that by adding a check which stops the defaults from being set,
unless they are explicitly passed.
Fixes: https://github.com/oven-sh/bun/issues/6144
* [server] requestIp and AnyRequestContext
Changed Request.uws_request to the new AnyRequestContext. This
allows grabbing the IP from a Request. Unfinished.
* [server] basic `requestIp` implementation
Currently using uws's requestIpAsText, which always returns a ipv6
string. We should return a `SocketAddress` object to the user instead,
which will contain the formatted address string and what type it is.
We'll have to use requestIpAsBinary and parse that ourselves.
* TypeScript docs, use `bun.String`, return `undefined` instead of `null`
if we can't get the ip.
* binary address formatting
* uws getRemoteAddress binding
* remove dead code
* working
* final touches✨
* I will abide by the results of this poll.
---------
Co-authored-by: Parzival-3141 <29632054+Parzival-3141@users.noreply.github.com>
* check if the value passed for add command is a local tarball and install it, test for local tarball
* use bunExe()
* use absolute path to copy tarball
* fmt ts
* fix: implement correct behaviour for urls with blob: scheme
Urls using the blob scheme can have special behaviour if their origin itself
is a url.
This fixes that by parsing the subdomain and if valid and the schemes(protocols)
are valid returns its origin.
Ive used node.js here a lot to make sure its behaviour is copied 1:1 and enabled
the automated tests for it.
Fixes https://github.com/oven-sh/bun/issues/5805
* fix: subUrl can be const, we are not modifying it
* style: add spaces after `if` keyword
Using `RUN --mount`, we can run the command with the build stage files overlayed for the `ln` and `which` commands.
`/bin` is a symlink to `/usr/bin`, both seem required to work correctly.
* fix: support console,dir options object correctly
`console.dir` can be passed a second argument which is a object of options.
This implements that logic with the currently supported properties: `depth`
and `colors`.
I used node as a reference for implementation details.
Fixes: https://github.com/oven-sh/bun/issues/6039
* style: format zig file
* fix: implement changes from review
Implements changes requested from review, like adding
more test cases and refactoring code style.
* Update our MultiArrayList
* More consistent CI
* Fix serialization issue
* Update bun.lockb
* Update bun.lockb
* fixup
* Fix `Bin{}`
* `bun update` should not cache the manifest
* Make bun install tests more consistent
* This differs by platform evidently
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* Update installation.md
Adding notes for users that currently use canary version and want to switch back to stable version.
* Upadte
---------
Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
* fix: correctly pass the encrypted property on "Socket" for express.js
Express relies on this for setting the requests protocol.
Since this is on a dummy object, a property is simply set with the actual value.
Which seams okay as a workaround.
* chore: add generated files
* chore: add test
* refactor: set property directly rather then through a getter
* Fix `make jsc` on Linux
Previously, it failed with `/usr/bin/bash: Line 3: -DUSE_BUN_JSC_ADDITIONS=ON: Command not found`.
* Update Makefile
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
The sqlite3 logic to dynamically load extensions can be disabled to save space,
which macos does by default.
sqlite3 provides a api to check for these compile time settings at runtime,
we can use that to throw a js error rather then crashing.
It is worth noting though that the api to check for these settings at runtime
itself can be disabled through SQLITE_OMIT_COMPILEOPTION_DIAGS but this seams
to be a edge case.
* feat: switch disableTelemetry to bunfig
* feat: zig fmt
* revert: the env variable and invert the logic of telemetry
---------
Co-authored-by: MrPalixir <73360179+MrPalixir@users.noreply.github.com>
* some progess
* needs more tests
* make tests easier to debug
* get metadata for constructor arg decorators
* fix some things
* merge `emitDecoratorMetadata` option
* remove `^`
* bundler tests and get option from tsconfig earlier
* remove spaces
* fix tests
* Update modules.md
Updated docs to address `The ES modules aren't always asynchronous. #5420` Issue.
- Included an elaborate explanation citing the difference between CommonJS and ES Modules,
- Added a summary
* Tweaks
---------
Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
* Update Remix guide
* Update callout
* Update docs/guides/ecosystem/remix.md
Co-authored-by: Michael Jackson <michael@jackson.us>
* update
* Add link to remix
---------
Co-authored-by: Michael Jackson <michael@jackson.us>
Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
* Get artifactory to work
* Cleanup url normalization a ltitle more
* Clean up tests
* prettier
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* Fix empty file not found bug
* Add tests
* fix test
---------
Co-authored-by: Jeremy Funk <jeremy@kombo.dev>
Co-authored-by: dave caruso <me@paperdave.net>
* fix: provide empty string to len 0 process env vars
For process loaded env vars, its a bug to give them the literal value '""'
if the provided length is 0.
* fix: add test and remove unneeded branch
Removes the redundant branch for empty env vars and adds a test for the
process specific case.
* fix: remove empty_string_value
Removes the constant in favor of using the empty values or passing the
literal "".
* style: format env.test.ts
* make bufferconstructor a static hash table
* chore: Upgrade WebKit to 4d995edbc44062b251be638818edcd88d7d14dd7
* make it constructable now
* fix comment
* yippee
* update CI workflows
* Fix HTTP listen behavior being non-compliant with node
* Add error code for address in use
* use SystemError
---------
Co-authored-by: SuperAuguste <19855629+SuperAuguste@users.noreply.github.com>
* Make sure we set the number tag correctly when returning values from SQLite
* Add DOMJIT test
* Update JSSQLStatement.cpp
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* feat(test): implement `arrayContaining`
* feat: early return when expectedArray is empty
* feat: add test for toEqual
* chore: use `JSC::isArray`
* chore: use getIndex for performance
* fix: use deepEqual
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* binding uv
* we did that
* some more bindings
* fix doc
* fix uv
* yo
* static hash table nonsense <3
* huge refactor to the global object i am not ready for merge conflicts
* it works part 3
* lose
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* track one shot fds
* dup fd
* skip for rearm on mac
* dup if fd
* cleanup
* force unregister on close
* deinitForceUnregister
* test
* add prompts
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* allow multiple set-cookie values
* make it work for `getHeader`
* move `getHeader` to cpp
* remove set-cookie check
* move `setHeader` to cpp
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* Create v8-date-parser.test.js
* one more test
* add permalinks and enable parser in bun
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
I have removed the / before ${server.port} because it its incorrect and I replaced the localhost to ${server.hostname}
Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
* doc(guides): update sveltekit guide
Use `bun create svelte` instead of `bunx create-svelte`.
This is to bring the documentation at par with the SvelteKit official doc to [create a project](https://kit.svelte.dev/docs/creating-a-project).
* Update text instructions for sveltekit.md
Reading the documentation on bun-types it was not clear to me that the tsconfig.ts needs to look like this:
```
{
"compilerOptions": {
"types": ["bun-types"]
}
}
```
So i added the "compilerOptions" information.
* avoid overflow
* Update src/bun.js/bindings/exports.zig
* add mongodb inspect test
* bun db test
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
it's always good to have uninstall instructions as well as install, and I couldn't find them anywhere else on the site.
IMO, this gives users a little more confidence to try new tools out, as they know it's easily reversible.
I'm not familiar with how to uninstall with Docker, so would appreciate some help there.
We could possibly add a note for "bash" on how to remove Bun from the `$PATH`.
* Support named exports in json imports
* Support named imports for `*.json` files
* Remove stale comments
* Don't export arrays as non-default
* Add test for default exports
* Don't break webpack
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* Update Svelte Kit Docs
I added some guidance about how to build for production. Still WIP since I would like to add a more complete deployment guide.
* Formatting
---------
Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
This section appears to have been accidentally moved into the low-level details section in 5424ea3403.
This fixes the example in the low-level details section, because the "Importing CJS from CJS" section is not the example code that the low-level details section is intended to provide.
Terminals like iTerm require valid URL to make them clickable. Adding a space to make it valid. Similar problem is on https://bun.sh/, where protocol is missing.
* closeAndFail instead of close
* use constant
* add some protection
* dont deinit
---------
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
* enable root certs on fetch
* rebase
* fix lookup
* some fixes and improvements
* fmt
* more fixes
* more fixes
* check detached onHandshake
* fix promise case
* fix cert non-Native
* add fetch tls tests
* more one test
description:Report an issue during install or upgrade
labels:[bug, install]
body:
- type:markdown
attributes:
value:|
Thank you for submitting a bug report. It helps make Bun better.
If you need help or support using Bun, and are not reporting an issue, please
join our [Discord](https://discord.gg/CXdq2DP29u) server, where you can ask questions in the [`#help`](https://discord.gg/32EtH6p7HN) forum.
Please try to include as much information as possible.
- 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:How did you attempt to install or upgrade?
description:Please provide the commands you ran to install or upgrade.
validations:
required:true
- type:textarea
attributes:
label:What do you see instead?
description:If possible, please provide text instead of a screenshot.
validations:
required:true
- type:textarea
attributes:
label:Additional information
description:Is there anything else you think we should know?
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?
@${{ github.actor }}, there are ${{ steps.test.outputs.failing_tests_count }} files with test failures on bun-windows-${{ matrix.arch }}-${{ matrix.cpu }}
${{ steps.test.outputs.failing_tests }}
**[View test output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
You might need to run `bun install` locally and configure your text editor to [auto-format on save](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode).
echo "// The following errors occurred:" >> "${GITHUB_OUTPUT}"
cat zig-fmt.err >> "${GITHUB_OUTPUT}"
fi
if [ -s zig-fmt.err2 ]; then
echo "// The following files were not formatted:" >> "${GITHUB_OUTPUT}"
cat zig-fmt.err2 >> "${GITHUB_OUTPUT}"
fi
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
- name:Comment on PR
if:steps.fmt.outputs.zig_fmt_errs != ''
uses:thollander/actions-comment-pull-request@v2
with:
comment_tag:zig-fmt
message:|
❌ @${{ github.actor }} `zig fmt` reported errors. Consider configuring your text editor to [auto-format on save](https://github.com/ziglang/vscode-zig)
> **Bun is still under 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.
```bash
bun run index.tsx # TS and JSX supported outofthebox
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`
Report any discovered vulnerabilities to the Bun team by emailing `security@bun.sh`. Your report will acknowledged within 5 days, and a team member will be assigned as the primary handler. To the greatest extent possible, the security team will endeavor to keep you informed of the progress being made towards a fix and full announcement, and may ask for additional information or guidance surrounding the reported issue.
Requires [`hyperfine`](https://github.com/sharkdp/hyperfine). The goal of this benchmark is to compare installation performance of Bun with other package managers _when caches are hot_.
```
### With lockfile, online mode
To run the benchmark with the standard "install" command for each package manager:
Even though all packages are cached, some tools may hit the npm API during the version resolution step. (This is not the same as re-downloading a package.) To entirely avoid network calls, the other package managers require `--prefer-offline/--offline` flag. To run the benchmark using "offline" mode:
@compileError("The minimum version of Zig required to compile Bun is "++recommended_zig_version++", found "++@import("builtin").zig_version_string++". Please follow the instructions at https://bun.sh/docs/project/contributing. You may need to re-run `bun setup`.");
"{s}WARNING:\nBun recommends Zig version '{s}', but found '{s}', build may fail...\nMake sure you are following the instructions at https://bun.sh/docs/project/contributing\n{s}You can update to the right version using 'zigup {s}'\n\n",
.{
if(colors)"\x1b[1;33m"else"",
recommended_zig_version,
builtin.zig_version_string,
if(colors)"\x1b[0m"else"",
recommended_zig_version,
},
);
},
}
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
@@ -51,7 +51,7 @@ function __bun_last_cmd --argument-names n
end
set-lbun_install_boolean_flags yarn production optional development no-save dry-run force no-cache silent verbose global
set-lbun_install_boolean_flags_descriptions"Write a yarn.lock file (yarn v1)""Don't install devDependencies""Add dependency to optionalDependencies""Add dependency to devDependencies""Don't install devDependencies""Don't install anything""Always request the latest versions from the registry & reinstall all dependenices""Ignore manifest cache entirely""Don't output anything""Excessively verbose logging""Use global folder"
set-lbun_install_boolean_flags_descriptions"Write a yarn.lock file (yarn v1)""Don't install devDependencies""Add dependency to optionalDependencies""Add dependency to devDependencies""Don't install devDependencies""Don't install anything""Always request the latest versions from the registry & reinstall all dependencies""Ignore manifest cache entirely""Don't output anything""Excessively verbose logging""Use global folder"
set-lbun_builtin_cmds dev create help bun upgrade discord run install remove add init link unlink pm x
set-lbun_builtin_cmds_without_run dev create help bun upgrade discord install remove add init pm x
@@ -26,10 +26,10 @@ Below is a quick "cheat sheet" that doubles as a table of contents. Click an ite
---
<!-- - [`File`](#file)
- _Browser only_. A subclass of `Blob` that represents a file. Has a `name` and `lastModified` timestamp. There is experimental support in Node.js v20; Bun does not support `File` yet; most of its functionality is provided by `BunFile`.
- [`File`](#file)
- A subclass of `Blob` that represents a file. Has a `name` and `lastModified` timestamp. There is experimental support in Node.js v20.
--- -->
---
- [`BunFile`](#bunfile)
- _Bun only_. A subclass of `Blob` that represents a lazily-loaded file on disk. Created with `Bun.file(path)`.
@@ -49,7 +49,6 @@ Despite the name, it isn't an array and supports none of the array methods and o
```ts
constbuf=newArrayBuffer(8);
buf.byteLength;// => 8
constslice=buf.slice(0,4);// returns new ArrayBuffer
@@ -66,19 +65,19 @@ Below we create a new `DataView` and set the first byte to 5.
Now lets write a `Uint16` at byte offset `1`. This requires two bytes. We're using the value `513`, which is `2 * 256 + 1`; in bytes, that's `00000010 00000001`.
Now let's write a `Uint16` at byte offset `1`. This requires two bytes. We're using the value `513`, which is `2 * 256 + 1`; in bytes, that's `00000010 00000001`.
Attempting to write a value that requires more space than is available in the underlying `ArrayBuffer` will cuase an error. Below we attempt to write a `Float64` (which requires 8 bytes) at byte offset `0`, but there are only four total bytes in the buffer.
Attempting to write a value that requires more space than is available in the underlying `ArrayBuffer` will cause an error. Below we attempt to write a `Float64` (which requires 8 bytes) at byte offset `0`, but there are only four total bytes in the buffer.
```ts
dv.setFloat64(0,3.1415);
@@ -412,7 +411,7 @@ For complete documentation, refer to the [Node.js documentation](https://nodejs.
`Blob` is a Web API commonly used for representing files. `Blob` was initially implemented in browsers (unlike `ArrayBuffer` which is part of JavaScript itself), but it is now supported in Node and Bun.
It isn't common to directly create `Blob` instances. More often, you'll recieve instances of `Blob` from an external source (like an `<input type="file">` element in the browser) or library. That said, it is possible to create a `Blob` from one or more string or binary "blob parts".
It isn't common to directly create `Blob` instances. More often, you'll receive instances of `Blob` from an external source (like an `<input type="file">` element in the browser) or library. That said, it is possible to create a `Blob` from one or more string or binary "blob parts".
```ts
constblob=newBlob(["<html>Hello</html>"],{
@@ -507,7 +506,7 @@ for await (const chunk of stream) {
}
```
For a more complete discusson of streams in Bun, see [API > Streams](/docs/api/streams).
For a more complete discussion of streams in Bun, see [API > Streams](/docs/api/streams).
@@ -376,10 +400,6 @@ If you want to track when a `TypedArray` is no longer in use from JavaScript, yo
#### From C, Rust, Zig, etc
{% callout %}
**Note** — Available in Bun v0.1.8 and later.
{% /callout %}
If you want to track when a `TypedArray` is no longer in use from C or FFI, you can pass a callback and an optional context pointer to `toArrayBuffer` or `toBuffer`. This function is called at some point later, once the garbage collector frees the underlying `ArrayBuffer` JavaScript object.
The expected signature is the same as in [JavaScriptCore's C API](https://developer.apple.com/documentation/javascriptcore/jstypedarraybytesdeallocator?language=objc):
<!-- **Note** — The `Bun.file` and `Bun.write` APIs documented on this page are heavily optimized and represent the recommended way to perform file-system tasks using Bun. Existing Node.js projects may use Bun's [nearly complete](/docs/runtime/nodejs-apis#node-fs) implementation of the [`node:fs`](https://nodejs.org/api/fs.html) module. -->
**Note** — The `Bun.file` and `Bun.write` APIs documented on this page are heavily optimized and represent the recommended way to perform file-system tasks using Bun. For operations that are not yet available with `Bun.file`, such as `mkdir`, you can use Bun's [nearly complete](/docs/runtime/nodejs-apis#node-fs) implementation of the [`node:fs`](https://nodejs.org/api/fs.html) module.
**Note** — The `Bun.file` and `Bun.write` APIs documented on this page are heavily optimized and represent the recommended way to perform file-system tasks using Bun. For operations that are not yet available with `Bun.file`, such as `mkdir` or `readdir`, you can use Bun's [nearly complete](/docs/runtime/nodejs-apis#node-fs) implementation of the [`node:fs`](https://nodejs.org/api/fs.html) module.
Bun's implementation of `node:fs` is fast, and we haven't implemented a Bun-specific API for reading directories just yet. For now, you should use `node:fs` for working with directories in Bun.
### Reading directories (readdir)
To read a directory in Bun, use `readdir` from `node:fs`.
```ts
import{readdir}from"node:fs/promises";
// read all the files in the current directory
constfiles=awaitreaddir(import.meta.dir);
```
#### Reading directories recursively
To recursively read a directory in Bun, use `readdir` with `recursive: true`.
```ts
import{readdir}from"node:fs/promises";
// read all the files in the current directory, recursively
constfiles=awaitreaddir("../",{recursive: true});
```
### Creating directories (mkdir)
To recursively create a directory, use `mkdir` in `node:fs`:
```ts
import{mkdir}from"node:fs/promises";
awaitmkdir("path/to/dir",{recursive: true});
```
## Benchmarks
The following is a 3-line implementation of the Linux `cat` command.
@@ -300,7 +336,7 @@ interface BunFile {
readonly type: string;
text(): Promise<string>;
stream(): Promise<ReadableStream>;
stream(): ReadableStream;
arrayBuffer(): Promise<ArrayBuffer>;
json(): Promise<any>;
writer(params: { highWaterMark?: number }): FileSink;
* The root directory to start matching from. Defaults to `process.cwd()`
*/
cwd?: string;
/**
* Allow patterns to match entries that begin with a period (`.`).
*
* @default false
*/
dot?: boolean;
/**
* Return the absolute path for entries.
*
* @default false
*/
absolute?: boolean;
/**
* Indicates whether to traverse descendants of symbolic link directories.
*
* @default false
*/
followSymlinks?: boolean;
/**
* Throw an error when symbolic link is broken
*
* @default false
*/
throwErrorOnBrokenSymlink?: boolean;
/**
* Return only files.
*
* @default true
*/
onlyFiles?: boolean;
}
```
## Supported Glob Patterns
Bun supports the following glob patterns:
### `?` - Match any single character
```ts
constglob=newGlob("???.ts");
glob.match("foo.ts");// => true
glob.match("foobar.ts");// => false
```
### `*` - Matches zero or more characters, except for path separators (`/` or `\`)
```ts
constglob=newGlob("*.ts");
glob.match("index.ts");// => true
glob.match("src/index.ts");// => false
```
### `**` - Match any number of characters including `/`
```ts
constglob=newGlob("**/*.ts");
glob.match("index.ts");// => true
glob.match("src/index.ts");// => true
glob.match("src/index.js");// => false
```
### `[ab]` - Matches one of the characters contained in the brackets, as well as character ranges
```ts
constglob=newGlob("ba[rz].ts");
glob.match("bar.ts");// => true
glob.match("baz.ts");// => true
glob.match("bat.ts");// => false
```
You can use character ranges (e.g `[0-9]`, `[a-z]`) as well as the negation operators `^` or `!` to match anything _except_ the characters contained within the braces (e.g `[^ab]`, `[!a-z]`)
```ts
constglob=newGlob("ba[a-z][0-9][^4-9].ts");
glob.match("bar01.ts");// => true
glob.match("baz83.ts");// => true
glob.match("bat22.ts");// => true
glob.match("bat24.ts");// => false
glob.match("ba0a8.ts");// => false
```
### `{a,b,c}` - Match any of the given patterns
```ts
constglob=newGlob("{a,b,c}.ts");
glob.match("a.ts");// => true
glob.match("b.ts");// => true
glob.match("c.ts");// => true
glob.match("d.ts");// => false
```
These match patterns can be deeply nested (up to 10 levels), and contain any of the wildcards from above.
### `!` - Negates the result at the start of a pattern
```ts
constglob=newGlob("!index.ts");
glob.match("index.ts");// => false
glob.match("foo.ts");// => true
```
### `\` - Escapes any of the special characters above
After the data has been feed into the hasher, a final hash can be computed using `.digest()`. By default, this method returns a `Uint8Array` containing the hash.
To handle server-side errors, implement an `error` handler. This function should return a `Response` to served to the client when an error occurs. This response will supercede Bun's default error page in `development` mode.
To handle server-side errors, implement an `error` handler. This function should return a `Response` to serve to the client when an error occurs. This response will supersede Bun's default error page in `development` mode.
```ts
Bun.serve({
@@ -140,12 +140,6 @@ Bun.serve({
});
```
{% callout %}
**Note** —Earlier versions of Bun supported passing a file path as `keyFile` and `certFile`; this has been deprecated as of `v0.6.3`.
{% /callout %}
If your private key is encrypted with a passphrase, provide a value for `passphrase` to decrypt it.
```ts-diff
@@ -177,14 +171,14 @@ Optionally, you can override the trusted CA certificates by passing a value for
});
```
To override Diffie-Helman parameters:
To override Diffie-Hellman parameters:
```ts
Bun.serve({
// ...
tls: {
// other config
dhParamsFile: "/path/to/dhparams.pem", // path to Diffie Helman parameters
dhParamsFile: "/path/to/dhparams.pem", // path to Diffie Hellman parameters
},
});
```
@@ -198,7 +192,7 @@ import {type Serve} from "bun";
export default {
fetch(req) {
return new Response(`Bun!`);
return new Response("Bun!");
},
} satisfies Serve;
```
@@ -218,9 +212,7 @@ $ bun --hot server.ts
To stream a file, return a `Response` object with a `BunFile` object as the body.
```ts
import { serve, file } from "bun";
serve({
Bun.serve({
fetch(req) {
return new Response(Bun.file("./hello.txt"));
},
@@ -231,7 +223,7 @@ serve({
⚡️ **Speed** — Bun automatically uses the [`sendfile(2)`](https://man7.org/linux/man-pages/man2/sendfile.2.html) system call when possible, enabling zero-copy file transfers in the kernel—the fastest way to send files.
{% /callout %}
**[v0.3.0+]** You can send part of a file using the [`slice(start, end)`](https://developer.mozilla.org/en-US/docs/Web/API/Blob/slice) method on the `Bun.file` object. This automatically sets the `Content-Range` and `Content-Length` headers on the `Response` object.
You can send part of a file using the [`slice(start, end)`](https://developer.mozilla.org/en-US/docs/Web/API/Blob/slice) method on the `Bun.file` object. This automatically sets the `Content-Range` and `Content-Length` headers on the `Response` object.
```ts
Bun.serve({
@@ -260,7 +252,7 @@ Below are Bun and Node.js implementations of a simple HTTP server that responds
- An alias to `import.meta.dir`, for Node.js compatibility
---
- `import.meta.env`
- An alias to `process.env`.
---
- `import.meta.file`
- The name of the current file, e.g. `index.tsx`
---
- `import.meta.path`
- Absolute path to the current file, e.g. `/path/to/project/index.tx`. Equivalent to `__filename` in CommonJS modules (and Node.js)
- Absolute path to the current file, e.g. `/path/to/project/index.ts`. Equivalent to `__filename` in CommonJS modules (and Node.js)
---
- `import.meta.filename`
- An alias to `import.meta.path`, for Node.js compatibility
---
- `import.meta.main`
- `boolean` Indicates whether the current file is the entrypoint to the current `bun` process. Is the file being directly executed by `bun run` or is it being imported?
- Indicates whether the current file is the entrypoint to the current `bun` process. Is the file being directly executed by `bun run` or is it being imported?
---
- `import.meta.resolve{Sync}`
- Resolve a module specifier (e.g. `"zod"` or `"./file.tsx`) to an absolute path. While file would be imported if the specifier were imported from this file?
- `import.meta.resolve`
- Resolve a module specifier (e.g. `"zod"` or `"./file.tsx"`) to a url. Equivalent to [`import.meta.resolve` in browsers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta#resolve)
- A `string` url to the current file, e.g. `file:///path/to/project/index.ts`. Equivalent to [`import.meta.url` in browsers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta#url)
Bun implements a semantic versioning API which can be used to compare versions and determine if a version is compatible with another range of versions. The versions and ranges are designed to be compatible with `node-semver`, which is used by npm clients.
Bun supports direct inter-process communication channel between two `bun` processes. To receive messages from a spawned Bun subprocess, specify an `ipc` handler.
{%callout%}
**Note** — This API is only compatible with other `bun` processes. Use `process.execPath` to get a path to the currently running `bun` executable.
{%/callout%}
```ts#parent.ts
const child = Bun.spawn(["bun", "child.ts"], {
ipc(message) {
/**
* The message received from the sub process
**/
},
});
```
The parent process can send messages to the subprocess using the `.send()` method on the returned `Subprocess` instance. A reference to the sending subprocess is also available as the second argument in the `ipc` handler.
childProc.send("I am your father"); // The parent can send messages to the child as well
```
Meanwhile the child process can send messages to its parent using with `process.send()` and receive messages with `process.on("message")`. This is the same API used for `child_process.fork()` in Node.js.
```ts#child.ts
process.send("Hello from child as string");
process.send({ message: "Hello from child as object" });
process.on("message", (message) => {
// print message from parent
console.log(message);
});
```
```ts#child.ts
// send a string
process.send("Hello from child as string");
// send an object
process.send({ message: "Hello from child as object" });
```
The `ipcMode` option controls the underlying communication format between the two processes:
- `advanced`: (default) Messages are serialized using the JSC `serialize` API, which supports cloning [everything `structuredClone` supports](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm). This does not support transferring ownership of objects.
- `json`: Messages are serialized using `JSON.stringify` and `JSON.parse`, which does not support as many object types as `advanced` does.
## Blocking API (`Bun.spawnSync()`)
Bun provides a synchronous equivalent of `Bun.spawn` called `Bun.spawnSync`. This is a blocking API that supports the same inputs and parameters as `Bun.spawn`. It returns a `SyncSubprocess` object, which differs from `Subprocess` in a few ways.
@@ -209,7 +269,7 @@ Bun's `spawnSync` spawns processes 60% faster than the Node.js `child_process` m
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.