aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/JSReadableState.cpp
diff options
context:
space:
mode:
authorGravatar Derrick Farris <mr.dcfarris@gmail.com> 2022-12-15 02:25:19 -0600
committerGravatar GitHub <noreply@github.com> 2022-12-15 00:25:19 -0800
commit6a1fc208354d173a66b61060ec5bb79699038006 (patch)
treeab5af3660f1ce2d8b2ac8eee154ba21221a0acd4 /src/bun.js/bindings/JSReadableState.cpp
parent95c747f598ff0a57335f2cb35c008132b7a3ac2b (diff)
downloadbun-6a1fc208354d173a66b61060ec5bb79699038006.tar.gz
bun-6a1fc208354d173a66b61060ec5bb79699038006.tar.zst
bun-6a1fc208354d173a66b61060ec5bb79699038006.zip
fix(stream): make Readable.read work w/o _construct implemented (#1613)
* fix(stream): put Readable._readableState.constructed default in spec (true, not false) * cleanup(readable): remove unnecessary _construct methods * test(stream): add test for Readable w/o _construct method
Diffstat (limited to 'src/bun.js/bindings/JSReadableState.cpp')
-rw-r--r--src/bun.js/bindings/JSReadableState.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/bun.js/bindings/JSReadableState.cpp b/src/bun.js/bindings/JSReadableState.cpp
index 682e681f4..5b645e274 100644
--- a/src/bun.js/bindings/JSReadableState.cpp
+++ b/src/bun.js/bindings/JSReadableState.cpp
@@ -108,6 +108,12 @@ void JSReadableState::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObj
m_encoding.set(vm, this, JSC::jsNull());
}
}
+
+ // ReadableState.constructed is set to false during construction when a _construct method is implemented
+ // this is here so that the ReadableState behavior tracks the behavior in node, and that calling Readable.read
+ // will work when we return early from construct because there is no Readable._construct implemented
+ // See: https://github.com/nodejs/node/blob/main/lib/internal/streams/readable.js
+ setBool(JSReadableState::Mask::constructed, true);
}
const JSC::ClassInfo JSReadableState::s_info = { "ReadableState"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableState) };
@@ -305,9 +311,12 @@ JSReadableState_NULLABLE_BOOLEAN_GETTER_SETTER(paused)
#undef JSReadableState_JSVALUE_GETTER_SETTER
-#define JSReadableState_GETTER_SETTER_HASH_TABLE_VALUE(NAME) \
- { \
-#NAME ""_s, static_cast < unsigned>(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { HashTableValue::GetterSetterType, jsReadableState_##NAME, setJSReadableState_##NAME } \
+#define JSReadableState_GETTER_SETTER_HASH_TABLE_VALUE(NAME) \
+ { \
+#NAME ""_s, static_cast < unsigned>(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, \
+ { \
+ HashTableValue::GetterSetterType, jsReadableState_##NAME, setJSReadableState_##NAME \
+ } \
}
/* Hash table for prototype */