Merge and hopefully don't breka things along teh way

This commit is contained in:
Jarred Sumner
2024-03-07 03:07:48 -08:00
parent e0af083cbd
commit ad13b044cc
14 changed files with 157 additions and 134 deletions

18
.vscode/launch.json generated vendored
View File

@@ -430,9 +430,13 @@
"name": "BUN_DEBUG_QUIET_LOGS",
"value": "1"
},
{
"name": "BUN_DEBUG_jest",
"value": "1"
},
{
"name": "BUN_GARBAGE_COLLECTOR_LEVEL",
"value": "2"
"value": "1"
}
]
},
@@ -452,6 +456,18 @@
"name": "BUN_DEBUG_QUIET_LOGS",
"value": "1"
},
{
"name": "BUN_DEBUG_EventLoop",
"value": "1"
},
{
"name": "BUN_DEBUG_SYS",
"value": "1"
},
{
"name": "BUN_DEBUG_PipeWriter",
"value": "1"
},
{
"name": "BUN_GARBAGE_COLLECTOR_LEVEL",
"value": "2"

Binary file not shown.

View File

@@ -197,6 +197,7 @@ void us_loop_free(struct us_loop_t *loop) {
void us_loop_run(struct us_loop_t *loop) {
us_loop_integrate(loop);
uv_update_time(loop->uv_loop);
uv_run(loop->uv_loop, UV_RUN_ONCE);
}

View File

@@ -564,7 +564,7 @@ pub const ReadFileUV = struct {
on_complete_fn: ReadFile.OnReadFileCallback,
is_regular_file: bool = false,
req: libuv.fs_t = libuv.fs_t.uninitialized,
req: libuv.fs_t = std.mem.zeroes(libuv.fs_t),
pub fn start(loop: *libuv.Loop, store: *Store, off: SizeType, max_len: SizeType, comptime Handler: type, handler: *anyopaque) void {
log("ReadFileUV.start", .{});
@@ -630,7 +630,8 @@ pub const ReadFileUV = struct {
return;
}
this.req.assertCleanedUp();
this.req.deinit();
this.req.data = this;
if (libuv.uv_fs_fstat(this.loop, &this.req, bun.uvfdcast(opened_fd), &onFileInitialStat).errEnum()) |errno| {
this.errno = bun.errnoToZigErr(errno);

View File

@@ -1092,6 +1092,7 @@ pub fn WindowsStreamingWriter(
this.closeWithoutReporting();
return;
}
// success means that we send all the data inside current_payload
const written = this.current_payload.size();
this.current_payload.reset();

View File

@@ -364,6 +364,10 @@ export function windowsEnv(internalEnv: InternalEnvMap, envMapList: Array<string
return o;
};
(internalEnv as any).toJSON = () => {
return { ...internalEnv };
};
return new Proxy(internalEnv, {
get(_, p) {
return typeof p === "string" ? internalEnv[p.toUpperCase()] : undefined;

View File

@@ -1217,7 +1217,6 @@ class ChildProcess extends EventEmitter {
// TODO: better ipc support
const ipc = $isArray(stdio) && stdio[3] === "ipc";
var env = options.envPairs || undefined;
const detachedOption = options.detached;
this.#encoding = options.encoding || undefined;
@@ -1595,7 +1594,7 @@ const validateObject = (value, name, options = null) => {
const nullable = options?.nullable ?? false;
if (
(!nullable && value === null) ||
(!allowArray && ArrayIsArray.$call(value)) ||
(!allowArray && $isJSArray(value)) ||
(typeof value !== "object" && (!allowFunction || typeof value !== "function"))
) {
throw new ERR_INVALID_ARG_TYPE(name, "object", value);

View File

@@ -1,117 +1,117 @@
// Bun Snapshot v1, https://goo.gl/fbAQLP
exports[`Bun.build BuildArtifact properties: hash 1`] = `"e4885a8bc2de343a"`;
exports[`Bun.build BuildArtifact properties + entry.naming: hash 1`] = `"cb8abf3391c2971f"`;
exports[`Bun.build BuildArtifact properties sourcemap: hash index.js 1`] = `"e4885a8bc2de343a"`;
exports[`Bun.build BuildArtifact properties sourcemap: hash index.js.map 1`] = `"0000000000000000"`;
exports[`Bun.build Bun.write(BuildArtifact) 1`] = `
"var __defProp = Object.defineProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, {
get: all[name],
enumerable: true,
configurable: true,
set: (newValue) => all[name] = () => newValue
});
};
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
// test/bundler/fixtures/trivial/fn.js
var exports_fn = {};
__export(exports_fn, {
fn: () => {
{
return fn;
}
}
});
function fn(a) {
return a + 42;
}
var init_fn = __esm(() => {
});
// test/bundler/fixtures/trivial/index.js
var NS = Promise.resolve().then(() => (init_fn(), exports_fn));
NS.then(({ fn: fn2 }) => {
console.log(fn2(42));
});
"
`;
exports[`Bun.build outdir + reading out blobs works 1`] = `
"var __defProp = Object.defineProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, {
get: all[name],
enumerable: true,
configurable: true,
set: (newValue) => all[name] = () => newValue
});
};
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
// test/bundler/fixtures/trivial/fn.js
var exports_fn = {};
__export(exports_fn, {
fn: () => {
{
return fn;
}
}
});
function fn(a) {
return a + 42;
}
var init_fn = __esm(() => {
});
// test/bundler/fixtures/trivial/index.js
var NS = Promise.resolve().then(() => (init_fn(), exports_fn));
NS.then(({ fn: fn2 }) => {
console.log(fn2(42));
});
"
`;
exports[`Bun.build new Response(BuildArtifact) sets content type: response text 1`] = `
"var __defProp = Object.defineProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, {
get: all[name],
enumerable: true,
configurable: true,
set: (newValue) => all[name] = () => newValue
});
};
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
// test/bundler/fixtures/trivial/fn.js
var exports_fn = {};
__export(exports_fn, {
fn: () => {
{
return fn;
}
}
});
function fn(a) {
return a + 42;
}
var init_fn = __esm(() => {
});
// test/bundler/fixtures/trivial/index.js
var NS = Promise.resolve().then(() => (init_fn(), exports_fn));
NS.then(({ fn: fn2 }) => {
console.log(fn2(42));
});
"
`;
// Bun Snapshot v1, https://goo.gl/fbAQLP
exports[`Bun.build BuildArtifact properties: hash 1`] = `"e4885a8bc2de343a"`;
exports[`Bun.build BuildArtifact properties + entry.naming: hash 1`] = `"cb8abf3391c2971f"`;
exports[`Bun.build BuildArtifact properties sourcemap: hash index.js 1`] = `"e4885a8bc2de343a"`;
exports[`Bun.build BuildArtifact properties sourcemap: hash index.js.map 1`] = `"0000000000000000"`;
exports[`Bun.build Bun.write(BuildArtifact) 1`] = `
"var __defProp = Object.defineProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, {
get: all[name],
enumerable: true,
configurable: true,
set: (newValue) => all[name] = () => newValue
});
};
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
// test/bundler/fixtures/trivial/fn.js
var exports_fn = {};
__export(exports_fn, {
fn: () => {
{
return fn;
}
}
});
function fn(a) {
return a + 42;
}
var init_fn = __esm(() => {
});
// test/bundler/fixtures/trivial/index.js
var NS = Promise.resolve().then(() => (init_fn(), exports_fn));
NS.then(({ fn: fn2 }) => {
console.log(fn2(42));
});
"
`;
exports[`Bun.build outdir + reading out blobs works 1`] = `
"var __defProp = Object.defineProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, {
get: all[name],
enumerable: true,
configurable: true,
set: (newValue) => all[name] = () => newValue
});
};
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
// test/bundler/fixtures/trivial/fn.js
var exports_fn = {};
__export(exports_fn, {
fn: () => {
{
return fn;
}
}
});
function fn(a) {
return a + 42;
}
var init_fn = __esm(() => {
});
// test/bundler/fixtures/trivial/index.js
var NS = Promise.resolve().then(() => (init_fn(), exports_fn));
NS.then(({ fn: fn2 }) => {
console.log(fn2(42));
});
"
`;
exports[`Bun.build new Response(BuildArtifact) sets content type: response text 1`] = `
"var __defProp = Object.defineProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, {
get: all[name],
enumerable: true,
configurable: true,
set: (newValue) => all[name] = () => newValue
});
};
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
// test/bundler/fixtures/trivial/fn.js
var exports_fn = {};
__export(exports_fn, {
fn: () => {
{
return fn;
}
}
});
function fn(a) {
return a + 42;
}
var init_fn = __esm(() => {
});
// test/bundler/fixtures/trivial/index.js
var NS = Promise.resolve().then(() => (init_fn(), exports_fn));
NS.then(({ fn: fn2 }) => {
console.log(fn2(42));
});
"
`;

View File

@@ -78,14 +78,14 @@ describe("process.stdin", () => {
child.stdin.end(input);
});
it("should allow us to read > 65kb from stdin", done => {
it.only("should allow us to read > 65kb from stdin", done => {
const numReps = Math.ceil((1024 * 1024) / 5);
const input = Buffer.alloc("hello".length * numReps)
.fill("hello")
.toString();
// Child should read from stdin and write it back
const child = spawn(bunExe(), [CHILD_PROCESS_FILE, "STDIN", "FLOWING"], {
env: { ...bunEnv, BUN_DEBUG_QUIET_LOGS: "0", BUN_DEBUG: "/tmp/out.log" },
env: { ...bunEnv, BUN_DEBUG_QUIET_LOGS: "1" },
stdio: ["pipe", "pipe", "inherit"],
});
let data = "";

View File

@@ -1,2 +1,3 @@
// TODO - bun has no `send` method in the process
process?.send({ env: process.env });
const out = { env: { ...process.env } };
process?.send(out);

View File

@@ -1481,7 +1481,7 @@ describe("rmdirSync", () => {
});
});
describe.skipIf(isWindows)("createReadStream", () => {
describe("createReadStream", () => {
it("works (1 chunk)", async () => {
return await new Promise((resolve, reject) => {
var stream = createReadStream(import.meta.dir + "/readFileSync.txt", {});

View File

@@ -2,10 +2,10 @@ process.stdin.setEncoding("utf8");
process.stdin.on("data", data => {
process.stdout.write(data);
});
process.stdin.once(process.argv[2] == "close-event" ? "close" : "end", () => {
process.stdout.write(process.argv[2] == "close-event" ? "ENDED-CLOSE" : "ENDED");
process.stdin.once(process.argv[2] === "close-event" ? "close" : "end", () => {
process.stdout.write(process.argv[2] === "close-event" ? "ENDED-CLOSE" : "ENDED");
});
if (process.argv[2] == "resume") {
if (process.argv[2] === "resume") {
process.stdout.write("RESUMED");
process.stdin.resume();
}

View File

@@ -1,5 +1,5 @@
import { test, expect } from "bun:test";
import { spawnSync } from "bun";
import { spawn } from "bun";
import { bunEnv, bunExe } from "../../../harness";
import { join } from "path";
@@ -11,13 +11,13 @@ import { join } from "path";
//
// At the time of writing, this includes WebAssembly compilation and Atomics
// It excludes FinalizationRegistry since that doesn't need to keep the process alive.
test("es-module-lexer consistently loads", () => {
test("es-module-lexer consistently loads", async () => {
for (let i = 0; i < 10; i++) {
const { stdout, exitCode } = spawnSync({
const { stdout, exited } = spawn({
cmd: [bunExe(), join(import.meta.dir, "index.ts")],
env: bunEnv,
});
expect(JSON.parse(stdout?.toString())).toEqual({
expect(await new Response(stdout).json()).toEqual({
imports: [
{
n: "b",
@@ -40,6 +40,6 @@ test("es-module-lexer consistently loads", () => {
},
],
});
expect(exitCode).toBe(42);
expect(await exited).toBe(42);
}
});