aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp14
-rw-r--r--src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp3
-rw-r--r--src/bun.js/builtins/js/ReadableStream.js10
-rw-r--r--src/bun.js/builtins/js/ReadableStreamInternals.js1
-rw-r--r--test/bun.js/bunExe.ts7
-rw-r--r--test/bun.js/spawn-streaming-stdout-repro.js3
-rw-r--r--test/bun.js/spawn-streaming-stdout.test.ts25
7 files changed, 42 insertions, 21 deletions
diff --git a/src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp b/src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp
index cd14a15ea..86d40d4e8 100644
--- a/src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp
+++ b/src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp
@@ -567,15 +567,12 @@ const char* const s_readableStreamLockedCode =
const JSC::ConstructAbility s_readableStreamValuesCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const JSC::ConstructorKind s_readableStreamValuesCodeConstructorKind = JSC::ConstructorKind::None;
const JSC::ImplementationVisibility s_readableStreamValuesCodeImplementationVisibility = JSC::ImplementationVisibility::Public;
-const int s_readableStreamValuesCodeLength = 249;
+const int s_readableStreamValuesCodeLength = 191;
static const JSC::Intrinsic s_readableStreamValuesCodeIntrinsic = JSC::NoIntrinsic;
const char* const s_readableStreamValuesCode =
"(function (options) {\n" \
" \"use strict\";\n" \
- " var prototype = this?.constructor?.prototype;\n" \
- " if (!prototype) {\n" \
- " return @undefined;\n" \
- " }\n" \
+ " var prototype = @ReadableStream.prototype;\n" \
" @readableStreamDefineLazyIterators(prototype);\n" \
" return prototype.values.@call(this, options);\n" \
"})\n" \
@@ -584,15 +581,12 @@ const char* const s_readableStreamValuesCode =
const JSC::ConstructAbility s_readableStreamLazyAsyncIteratorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const JSC::ConstructorKind s_readableStreamLazyAsyncIteratorCodeConstructorKind = JSC::ConstructorKind::None;
const JSC::ImplementationVisibility s_readableStreamLazyAsyncIteratorCodeImplementationVisibility = JSC::ImplementationVisibility::Private;
-const int s_readableStreamLazyAsyncIteratorCodeLength = 259;
+const int s_readableStreamLazyAsyncIteratorCodeLength = 201;
static const JSC::Intrinsic s_readableStreamLazyAsyncIteratorCodeIntrinsic = JSC::NoIntrinsic;
const char* const s_readableStreamLazyAsyncIteratorCode =
"(function () {\n" \
" \"use strict\";\n" \
- " var prototype = this?.constructor?.prototype;\n" \
- " if (!prototype) {\n" \
- " return @undefined;\n" \
- " }\n" \
+ " var prototype = @ReadableStream.prototype;\n" \
" @readableStreamDefineLazyIterators(prototype);\n" \
" return prototype[globalThis.Symbol.asyncIterator].@call(this);\n" \
"})\n" \
diff --git a/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp b/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp
index a2b13e770..4b65667cf 100644
--- a/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp
+++ b/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp
@@ -2575,7 +2575,7 @@ const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode =
const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructorKind = JSC::ConstructorKind::None;
const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeImplementationVisibility = JSC::ImplementationVisibility::Public;
-const int s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeLength = 1651;
+const int s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeLength = 1650;
static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeIntrinsic = JSC::NoIntrinsic;
const char* const s_readableStreamInternalsReadableStreamDefineLazyIteratorsCode =
"(function (prototype) {\n" \
@@ -2618,7 +2618,6 @@ const char* const s_readableStreamInternalsReadableStreamDefineLazyIteratorsCode
" }\n" \
" }\n" \
" };\n" \
- "\n" \
" var createAsyncIterator = function asyncIterator() {\n" \
" return ReadableStreamAsyncIterator(this, false);\n" \
" };\n" \
diff --git a/src/bun.js/builtins/js/ReadableStream.js b/src/bun.js/builtins/js/ReadableStream.js
index 8020b024d..fb4327ec8 100644
--- a/src/bun.js/builtins/js/ReadableStream.js
+++ b/src/bun.js/builtins/js/ReadableStream.js
@@ -446,10 +446,7 @@ function locked()
function values(options) {
"use strict";
- var prototype = this?.constructor?.prototype;
- if (!prototype) {
- return @undefined;
- }
+ var prototype = @ReadableStream.prototype;
@readableStreamDefineLazyIterators(prototype);
return prototype.values.@call(this, options);
}
@@ -457,10 +454,7 @@ function values(options) {
@linkTimeConstant
function lazyAsyncIterator() {
"use strict";
- var prototype = this?.constructor?.prototype;
- if (!prototype) {
- return @undefined;
- }
+ var prototype = @ReadableStream.prototype;
@readableStreamDefineLazyIterators(prototype);
return prototype[globalThis.Symbol.asyncIterator].@call(this);
} \ No newline at end of file
diff --git a/src/bun.js/builtins/js/ReadableStreamInternals.js b/src/bun.js/builtins/js/ReadableStreamInternals.js
index ca1edaee8..c6115a456 100644
--- a/src/bun.js/builtins/js/ReadableStreamInternals.js
+++ b/src/bun.js/builtins/js/ReadableStreamInternals.js
@@ -2154,7 +2154,6 @@ function readableStreamDefineLazyIterators(prototype) {
}
}
};
-
var createAsyncIterator = function asyncIterator() {
return ReadableStreamAsyncIterator(this, false);
};
diff --git a/test/bun.js/bunExe.ts b/test/bun.js/bunExe.ts
new file mode 100644
index 000000000..2f1a89cd2
--- /dev/null
+++ b/test/bun.js/bunExe.ts
@@ -0,0 +1,7 @@
+export function bunExe() {
+ if (Bun.version.includes("debug")) {
+ return "bun-debug";
+ }
+
+ return "bun";
+}
diff --git a/test/bun.js/spawn-streaming-stdout-repro.js b/test/bun.js/spawn-streaming-stdout-repro.js
new file mode 100644
index 000000000..7279574bf
--- /dev/null
+++ b/test/bun.js/spawn-streaming-stdout-repro.js
@@ -0,0 +1,3 @@
+setInterval(() => {
+ console.log("Wrote to stdout");
+}, 20);
diff --git a/test/bun.js/spawn-streaming-stdout.test.ts b/test/bun.js/spawn-streaming-stdout.test.ts
new file mode 100644
index 000000000..88c028db3
--- /dev/null
+++ b/test/bun.js/spawn-streaming-stdout.test.ts
@@ -0,0 +1,25 @@
+import { it, test, expect } from "bun:test";
+import { spawn } from "bun";
+import { bunExe } from "./bunExe";
+
+test("spawn can read from stdout multiple chunks", async () => {
+ const proc = spawn({
+ cmd: [bunExe(), import.meta.dir + "/spawn-streaming-stdout-repro.js"],
+ stdout: "pipe",
+ env: {
+ BUN_DEBUG_QUIET_LOGS: 1,
+ },
+ });
+
+ var counter = 0;
+ for await (var chunk of proc.stdout) {
+ expect(new TextDecoder().decode(chunk)).toBe("Wrote to stdout\n");
+ counter++;
+
+ if (counter > 3) break;
+ }
+
+ expect(counter).toBe(4);
+ proc.kill();
+ await proc.exited;
+});