aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/webcore/blob.zig (follow)
AgeCommit message (Collapse)AuthorFilesLines
2023-10-13fix(error): correct the `path` field in syscall error message. (#6370)Gravatar Ai Hoshino 1-6/+23
* fix(error): correct the `path` field in syscall error message. Close: #6336 * fix pathlike union case
2023-10-03fix(blob): Add the current offset to the new blob. (#6259)Gravatar Ai Hoshino 1-1/+2
Close: #6252
2023-09-21Fix test failures (#5862)Gravatar Jarred Sumner 1-11/+1
* Fix test failures * Fixes #5851 --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-18fix: remove unneeded branch in toJSONWithBytes (#5684)Gravatar Liz 1-5/+1
This branch resulted in the same the same statement so having the branch, is not needed
2023-09-13fix(BunFile.slice) fix slice when length is greater than the size (#5186)Gravatar Ciro Spaciari 1-3/+5
* check the limits for file, when slicing * check eof * undo test
2023-08-31get name if not provided in `FormData.append` (#4434)Gravatar Dylan Conway 1-0/+9
* get file name from blob if not provided * add test * another test * format
2023-08-28More renamingGravatar Jarred Sumner 1-1/+1
2023-08-28just kernel32 things (#4354)Gravatar Jarred Sumner 1-63/+108
* just kernel32 things * more * Update linux_c.zig * Update windows_c.zig * Add workaround Workaround https://github.com/ziglang/zig/issues/16980 * Rename http.zig to bun_dev_http_server.zig * Rename usages * more * more * more * thanks tigerbeetle * Rename `JSC.Node.Syscall` -> `bun.sys` * more * woops * more! * hmm * it says there are only 37 errors, but that's not true * populate argv * it says 32 errors! * 24 errors * fix regular build * 12 left! * Still 12 left! * more * 2 errors left... * 1 more error * Add link to Tigerbeetle * Fix the remainign error * Fix test timeout * Update syscall.zig --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-08-26More improvements to debugger support (#4345)Gravatar Ashcon Partovi 1-2/+2
* More fixes for dap * More changes * More changes 2 * More fixes * Fix debugger.ts * Bun Terminal
2023-08-24Report extra memory more (#4289)Gravatar Jarred Sumner 1-0/+28
* Report memory allocated in fetch * Memory size reporting to `Headers` * Fixup memory reporting allocator * Make these tests do more * cleanup some of this --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-08-24update zig to 0.11.0 (#4233)Gravatar Jason 1-1/+1
* WIP * backup * more change * json related error sovled * number related issue solved * revert WriterType changed before * destroy -> free * jsonStringify related issues solved * fix mem.free expected []T or *[_]T, passed [*]const u8 * fix expected []T or *[_]T, passed [*:0]const u8 * fix build script * fix build script, for real * replace 0.11.0-dev.4006+bf827d0b5 to 0.12.0-dev.161+6a5463951 * fix build on macOS, COPYFILE.DATA -> COPYFILE_DATA * fix the last destroy on [*]ptr issue --------- Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
2023-08-21fetch(stream) add stream support for compressed and uncompressed data (#4127)Gravatar Ciro Spaciari 1-0/+20
* streams non compressed data in 64kb chunks (at least) * fmt * wip remove pause * fix default streaming and buffering * fix atomic lags * fix size * make chunked encoding work again (WIP streaming chunked) * WIP: chunked encoding streaming * fix end of streamings * working streaming + compression * add fixes + tests * fmt + fix proxy * fix oopsies * codegen after merge * fmt + fixes * more fixes * more fixes and logs * avoid double free * check empty before pop * check empty on pop * fix copy to real when complete * remove unnecessary logs * better has_schedule_callback swap, body locked size helper, remove isEmpty from unbounded_queue pop * fix response ref, fix body_size * add deflate support, fix error throw, add more tests * codegen after merge * remove logs, add connection close test * fix macOS build * fix redirect error option * make body_size more clear * support new Reponse(response) * toString DOMWrapper objects properly instead of supporting response in Response constructor * ignore headers with no name, add more tests * oops * handle transform with fetch * add gz image stream test * remove duplicate test * fix missing chunk on macOS under pressure * oops include all OS * some fixes * compare buffers instead of sizes * refactor err.err and protect it
2023-08-21Implement FileGravatar Jarred Sumner 1-2/+124
2023-08-20Fixes #1675 (#4230)Gravatar Jarred Sumner 1-1/+47
* Fixes https://github.com/oven-sh/bun/issues/1675 * Add fallback for Bun.write * Update blob.zig * Fix test --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-08-18Remove most C API usages, add debugger pretty printers for `Headers`, ↵Gravatar Jarred Sumner 1-82/+83
`URLSearchParams`, `FormData`, `Worker`, `EventTarget` (#4187) * Add pretty printers for `Headers`, `URLSearchParams`, and `FormData` * [untested] Add way to code generate getInternalProperties * bump * Bump Webkit * Ref the event loop while loaded * wip * checkpoint * another checkpoint * The code has been written * Fixup exports * Fix all the errors * Fix bug * [console.log] Fix bug when printing non-reified types missing values * Fix loading hash table * fix plugin * Fix ref & unref * auto-unref * various fixes * Update bun.zig * Set toStringTag * Delete code for macro JSX * Delete code for `bun dev` HTTP JS * Move Bun.serve to C++ API * Delete JSC C API code * :scissors: :skull: code * Use JSC C++ for `confirm`, `Crypto`, `prompt`, `alert` * more dead code * Update exports.zig * Use JSC C++ API for FFI * Remove remaining usages * Remove remaining usages * Update ffi.ts * Update InternalModuleRegistryConstants.h * draw the rest of the owl * Update webcore.zig * bind it * Fix performance regression in crypto.randomUIUD() * Update js_parser.zig --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-08-06Fixes #4001 (#4034)Gravatar Jarred Sumner 1-1/+2
* Avoid a utf8 conversion in isDetached * Fixes #4001 * hit the long url codepath --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-07-22Explicitly ref/unref blobs before extracting the value (#3755)Gravatar Jarred Sumner 1-0/+36
* Explicitly ref/unref blobs before extracting the value * :scissors: --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-07-22in Bun.write(), defer creating the Promise until we're just about to ↵Gravatar Jarred Sumner 1-4/+6
schedule the task
2023-07-22ref() before creating the JSPromiseGravatar Jarred Sumner 1-9/+14
2023-07-18zig upgrade (#3667)Gravatar Dylan Conway 1-60/+60
* upgrade * more fixes * Bump Zig --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-07-17Fix memory leak in `await new Response(latin1String).arrayBuffer()` and ↵Gravatar Jarred Sumner 1-2/+2
`await Response.json(obj).json()` (#3656) ❯ mem bun --smol response-arrayBuffer.mjs cpu: Apple M1 Max runtime: bun 0.6.15 (arm64-darwin) benchmark time (avg) (min … max) p75 p99 p995 --------------------------------------------------------------------------------------------------- ----------------------------- new Response().arrayBuffer() (new string each call, latin1) 12.9 µs/iter (625 ns … 4.18 ms) 1 µs 567.17 µs 711.79 µs new Response().arrayBuffer() (new string each call, utf16) 12.85 µs/iter (1.67 µs … 1.56 ms) 2.17 µs 462.75 µs 621.13 µs new Response().arrayBuffer() (existing string, latin1) 6.53 µs/iter (6.21 µs … 7.07 µs) 6.64 µs 7.07 µs 7.07 µs Peak memory usage: 49 MB bun on  jarred/memory-leak-fix took 2s ❯ mem bun response-arrayBuffer.mjs cpu: Apple M1 Max runtime: bun 0.6.15 (arm64-darwin) benchmark time (avg) (min … max) p75 p99 p995 --------------------------------------------------------------------------------------------------- ----------------------------- new Response().arrayBuffer() (new string each call, latin1) 1.2 µs/iter (1.04 µs … 1.42 µs) 1.22 µs 1.42 µs 1.42 µs new Response().arrayBuffer() (new string each call, utf16) 2.74 µs/iter (2.42 µs … 6.37 µs) 2.68 µs 6.37 µs 6.37 µs new Response().arrayBuffer() (existing string, latin1) 746.37 ns/iter (643.82 ns … 1.04 µs) 776.11 ns 1.04 µs 1.04 µs Peak memory usage: 104 MB bun on  jarred/memory-leak-fix took 2s ❯ mem ~/.bun/bin/bun response-arrayBuffer.mjs cpu: Apple M1 Max runtime: bun 0.6.15 (arm64-darwin) benchmark time (avg) (min … max) p75 p99 p995 --------------------------------------------------------------------------------------------------- ----------------------------- new Response().arrayBuffer() (new string each call, latin1) 1.69 µs/iter (1.56 µs … 2.1 µs) 1.73 µs 2.1 µs 2.1 µs new Response().arrayBuffer() (new string each call, utf16) 2.65 µs/iter (2.47 µs … 3.17 µs) 2.69 µs 3.17 µs 3.17 µs new Response().arrayBuffer() (existing string, latin1) 667.67 ns/iter (547.67 ns … 1.28 µs) 694.21 ns 1.28 µs 1.28 µs Peak memory usage: 2735 MB bun on  jarred/memory-leak-fix took 2s ❯ mem ~/.bun/bin/bun --smol response-arrayBuffer.mjs cpu: Apple M1 Max runtime: bun 0.6.15 (arm64-darwin) benchmark time (avg) (min … max) p75 p99 p995 --------------------------------------------------------------------------------------------------- ----------------------------- new Response().arrayBuffer() (new string each call, latin1) 13.51 µs/iter (541 ns … 3.2 ms) 1.92 µs 553.42 µs 709.92 µs new Response().arrayBuffer() (new string each call, utf16) 13.07 µs/iter (1.71 µs … 3.43 ms) 2.13 µs 451.21 µs 651.67 µs new Response().arrayBuffer() (existing string, latin1) 6.25 µs/iter (5.79 µs … 6.81 µs) 6.4 µs 6.81 µs 6.81 µs Peak memory usage: 292 MB Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-07-14structured clone (#3637)Gravatar Dylan Conway 1-0/+220
* copy `SerializedScriptValue` * format * make `SerializedScriptValue` compile * add `transfer` option * tests * serialize/deserialize blobs * tests for blobs * serialize/deserialize file blobs * more tests * small cleanup * format * small changes + serialize offset * slice helper * map and set test
2023-07-09fix metadata bits of uuid (`randomUUID()`) (#3583)Gravatar Ai Hoshino 1-1/+1
* fix uuid version Close: https://github.com/oven-sh/bun/issues/3575 * add unittest * small fix * avoid unnecessary copying
2023-07-01Use `BunString` in `SystemError` (#3485)Gravatar Jarred Sumner 1-29/+26
* Use `BunString` in SystemError * Use Bun::toStringRef when we will de-ref strings * Move `napi_create_error` to C++ to support `code` being a Symbol potentially * Update blob.zig * Make this test less flaky --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-06-28Introduce `await Bun.file(path).exists()` (#3446)Gravatar Jarred Sumner 1-0/+29
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-06-25Support reading embedded files in compiled executables (#3405)Gravatar Jarred Sumner 1-2/+34
* Support reading embedded files in compiled executables * :nail_care: --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-06-24Rewrite Bun's runtime CommonJS loader (#3379)Gravatar Jarred Sumner 1-56/+11
* wip changes for CommonJS * this rewrite is almost complete * even more code * wip * Remove usages of `import.meta.require` from builtins * Remove usages of require * Regenerate * :scissors: builtin rewrite commonjs in printer * Use lazy custom getters for import.meta * fixups * Remove depd * ugh * still crashing * fixup undici * comment out import.meta.require.resolve temporarily not a real solution but it stops the crashes * Redo import.meta.primordials * Builtins now have a `builtin://` protocol in source origin * Seems to work? * Finsih getting rid of primordials * switcharoo * No more function * just one more bug * Update launch.json * Implement `require.main` * :scissors: * Bump WebKit * Fixup import cycles * Fixup improt cycles * export more things * Implement `createCommonJSModule` builtin * More exports * regenerate * i broke some stuff * some of these tests work now * We lost the encoding * Sort of fix zlib * Sort of fix util * Update events.js * bump * bump * bump * Fix missing export in fs * fix some bugs with builtin esm modules (stream, worker_threads, events). its not perfect yet. * fix some other internal module bugs * oops * fix some extra require default stuff * uncomment this file but it crsahes on my machine * tidy code here * fixup tls exports * make simdutf happier * Add hasPrefix binding * Add test for `require.main` * Fix CommonJS evaluation order race condition * Make node:http load faster * Add missing exports to tls.js * Use the getter * Regenerate builtins * Fix assertion failure in Bun.write() * revamp dotEnv parser (#3347) - fixes `strings.indexOfAny()` - fixes OOB array access fixes #411 fixes #2823 fixes #3042 * fix tests for `expect()` (#3384) - extend test job time-out for `darwin-aarch64` * `expect().resolves` and `expect().rejects` (#3318) * Move expect and snapshots to their own files * expect().resolves and expect().rejects * Fix promise being added to unhandled rejection list * Handle timeouts in expect(<promise>) * wip merge * Fix merge issue --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> * fixup min/memcopy (#3388) * Fix crash in builtins * Don't attempt to evaluate modules with no source code * Update WebCoreJSBuiltins.cpp * Update WebCoreJSBuiltins.cpp * Update WebCoreJSBuiltins.cpp * Fix crash * cleanup * Fix test cc @paperdave * Fixup Undici * Fix issue in node:http * Create util-deprecate.mjs * Fix several bugs * Use the identifier * Support error.code in `util.deprecate` * make the CJs loader slightly more resilient * Update WebCoreJSBuiltins.cpp * Fix macros --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: dave caruso <me@paperdave.net> Co-authored-by: Alex Lam S.L <alexlamsl@gmail.com> Co-authored-by: Ashcon Partovi <ashcon@partovi.net> Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com>
2023-06-21upgrade zig to `v0.11.0-dev.3737+9eb008717` (#3374)Gravatar Dylan Conway 1-10/+10
* progress * finish `@memset/@memcpy` update * Update build.zig * change `@enumToInt` to `@intFromEnum` and friends * update zig versions * it was 1 * add link to issue * add `compileError` reminder * fix merge * format * upgrade to llvm 16 * Revert "upgrade to llvm 16" This reverts commit cc930ceb1c5b4db9614a7638596948f704544ab8. --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-06-13Fix crash in CJS (#3294)bun-v0.6.9Gravatar Jarred Sumner 1-1/+1
* Fix crash in CJS * Add std.heap.ArenaAllocator * Use our arena allocator * Reduce JS parser memory usage and make HMR faster * Write some comments * fix test failure & clean up this code * Update javascript.zig * make arena usage safer --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-06-11Support using `WTF::StringImpl` from Zig (#3279)Gravatar Jarred Sumner 1-5/+60
* Fix `make headers` * [JS parser] Fix bug with printing non-ascii import paths in ascii mode * Introduce `bun.String` * Add test for non-ascii imports & entry points * Add comment * Fix build issue * Support HTTP server * Make it print the same --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-31Support FormData & file uploads in `fetch` body (#3123)Gravatar Jarred Sumner 1-1/+44
* Fixes #2264 * fixup * Don't leak HTTP headers * Include the mime type. It's cleaner --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-30always clone theseGravatar Jarred Sumner 1-2/+2
2023-05-26Fix crash in test.todo + remove JSC C API usages in bun:test (#3079)Gravatar Jarred Sumner 1-1/+30
* Fix crash in test.todo * remove usages of JSC C API in bun:test * Remove additional JSC-C API usages * fix `make headers` * URLSearchParams.length * FormData length * URLSearchParams length * Fix `make headers` * very fancy length * Fix bug with exceptions being ignored sometimes * Add tests for extension toHaveLength --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-12fix large stdout output (#2850)Gravatar Ciro Spaciari 1-0/+16
* fix large stdout output * remove skip from #2674 for testing * add big stdout test using spawnSync * add bunEnv on big stdout test
2023-05-10Implement `BuildArtifact`Gravatar Jarred Sumner 1-0/+9
2023-05-09Add `name` propertyGravatar Jarred Sumner 1-0/+19
2023-05-08added some improvements on server (#2803)Gravatar Ciro Spaciari 1-1/+0
* added some improvements on server * undo unintended change * clean data handler before end calls * refactor * make ctx.resp nullable --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-04-28Improves Body.Value life cycle and Signal life cycle on server.zig (#2752)Gravatar Ciro Spaciari 1-7/+10
* reestruct request body value and signal * revert react-hello-world * fix constructInto and test * fmt * fix body nullable * Request can outlive RequestContext * fmt * BodyValue is now HiveRef * hasDecl for Ref and HiveRef * fix deinit call on Ref/HiveRef * adds InlineBlob * fix Bun.inspect when using InlineBlob * revert InlineBlob * Fix mimalloc-debug * Add TODO note * fix: make node:crypto Hash.copy work correctly (#2761) This commit will also: - add a CryptoHasher.copy function - make CryptoHasher.digest reset the hasher so it can be reused Resolves #2651 * :nail_care: * address unicode issue (#2763) * Fix an oopsie * Another oopsie * use inline for * Fixup --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> * Request can outlive RequestContext * fmt * garantee to have the abort signnal attached to the server before abort the client on bun-server test --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: Silver <14016168+silversquirl@users.noreply.github.com> Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-04-27Implement `outdir` in `Bun.build`Gravatar Jarred Sumner 1-1/+1
2023-04-21`Bun.build()` partial implementationGravatar Jarred Sumner 1-0/+8
2023-04-19Fix broken autocompleteGravatar Jarred Sumner 1-11/+11
2023-04-06Add last modify field "mtime" for FileBlob (#1431) (#2491)Gravatar Zhongwei Yao 1-33/+85
* Add lastModified field for FileBlob (#1431) lastModified value is epoch timestamp in millisecond unit. * update according to review comment.
2023-03-17Fix various fetch/response/request tests (#2416)Gravatar Dylan Conway 1-41/+10
* fix most fetch tests, skip a few * fastGet, toValueGC, and invalid init * bigint unreachable, range error, log process as process * remove extra fetch_headers * remove js_type parameter, check isObject() * throw invalid mime type error, use enum literal * switch back to promise rejection * RangeError pascal case
2023-03-14Implement `toMatchSnapshot()` (#2294)Gravatar Dylan Conway 1-1/+1
* buggy snapshot * error output for failed snapshot * missing first * hints * open dir once, better cleanup * update flag * truncate on update * object and class snapshot formatting * array formatting * no function name, single item is empty array * string objects, maps, sets, promise * avoid using invalid memory * handle number objects * handle extending `Number` * boolean objects * snapshot tests and test updates * snapshot format for buffers * safer snapshot parsing * property matchers setup * strings and tests * generate classes with empty prototype * optional `propertyMatchers` parameter * new test folder structure * strings.eqlLong * globalObject.throwPretty() and expect.any tests * add updateSnapshot flag to help * move snapshot format out of `printErrorlikeObject` * empty object snapshot format * separate typed array, remove trailing comma * use `isCell`, object trailing commas * handle unicode * todo for primitive constructors * switch to `JSC.Node.Syscall.open` and `JSC.Maybe` * use js parser for snapshot files * deinit ast, log parse error * copy/paste most of `exports.ZigConsoleClient` * remove snapshot option * remove ordered properties option * remove snapshot format option from `exports.zig` * remove extra newlines * change mode * update test runner output * escape backticks faster * `bunx jest` in temp dir * remove buffered writer * add `toMatchSnapshot` to types * cleanup, switch to `pread` * cli `--update` flag * `--update-snapshots` * remove string object format
2023-03-08More spec compliant `Blob.prototype.type` (#2340)Gravatar Jarred Sumner 1-40/+98
* Make `Blob.prototype. type` more spec compliant * Add a few more checks for isNumber() * Fix `make headers` * Safer JSValue.isString() * More tests for blob.slice * Make `Blob.prototype.type` more spec compliant * Add isASCII check * Fix types * Fix failing type test * Update blob.zig * Update blob.zig * Fix .eql check on empty values --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-03-05fix missing `Blob` error messages on Linux (#2315)Gravatar Alex Lam S.L 1-5/+5
2023-03-01fix Bun.file.arrayBuffer() segmentation fault on empty file #2248 (#2249)Gravatar Ciro Spaciari 1-7/+15
* fix Bun.file.arrayBuffer() segmentation fault on empty file #2248 * cleanner this.iotask check
2023-02-28Make response.body `null` only when user explicitly passes null/undefinedGravatar Jarred Sumner 1-0/+3
2023-02-23Upgrade Zig (#2151)Gravatar Dylan Conway 1-4/+4
* fixup * Upgrade Zig * Remove bad assertion * strings * bump * mode -> optimize * optimize * Linux build * Update bindgen.zig
2023-02-13Fixes https://github.com/oven-sh/bun/issues/1456Gravatar Jarred Sumner 1-0/+28