stream: add diagnostics_channel event for completion#42822
Open
bengl wants to merge 3 commits intonodejs:mainfrom
Open
stream: add diagnostics_channel event for completion#42822bengl wants to merge 3 commits intonodejs:mainfrom
bengl wants to merge 3 commits intonodejs:mainfrom
Conversation
bengl
commented
Apr 22, 2022
| let streamDoneChannel; | ||
| function getStreamDoneChannel () { | ||
| return streamDoneChannel ||= dc.channel('stream.web.done'); | ||
| } |
Member
Author
There was a problem hiding this comment.
Instead of this lazy-loading, I had tried to just create the channel immediately. However, this resulted in the following error at build time:
$ make -j24
ninja -C out/Release
ninja: Entering directory `out/Release'
[21/25] ACTION node: node_mksnapshot_9b7a2d2290b02e76d66661df74749f56
FAILED: gen/node_snapshot.cc
cd ../../; out/Release/node_mksnapshot out/Release/gen/node_snapshot.cc
global handle not serialized: 0x2c1d47302cd9: [JS_API_OBJECT_TYPE] in OldSpace
- map: 0x08188aa5fd61 <Map(HOLEY_ELEMENTS)> [FastProperties]
- prototype: 0x12df1ab07b79 <Object map = 0x8188aa5fd19>
- elements: 0x20e18df01329 <FixedArray[0]> [HOLEY_ELEMENTS]
- embedder fields: 1
- properties: 0x20e18df01329 <FixedArray[0]>
- All own properties (excluding elements): {}
- embedder fields = {
21965, aligned pointer: 0x55cde06a73c0
}
global handle not serialized: 0x2c1d47302b49: [JS_OBJECT_TYPE] in OldSpace
- map: 0x0f4b222452b9 <Map(HOLEY_ELEMENTS)> [FastProperties]
- prototype: 0x2c1d473027a9 <Channel map = 0xf4b22245229>
- elements: 0x20e18df01329 <FixedArray[0]> [HOLEY_ELEMENTS]
- properties: 0x20e18df01329 <FixedArray[0]>
- All own properties (excluding elements): {
0x218677ef8c49: [String] in OldSpace: #_subscribers: 0x20e18df015b9 <undefined> (const data field 0), location: in-object
0x20e18df058f1: [String] in ReadOnlySpace: #name: 0x218677ede9d1 <String[15]: #stream.web.done> (const data field 1), location: in-object
}
#
# Fatal error in , line 0
# Check failed: handle_checker.CheckGlobalAndEternalHandles().
#
#
#
#FailureMessage Object: 0x7ffefc883920
1: 0x55cddae43c35 [out/Release/node_mksnapshot]
2: 0x55cddbcc2926 V8_Fatal(char const*, ...) [out/Release/node_mksnapshot]
3: 0x55cddb396b05 v8::SnapshotCreator::CreateBlob(v8::SnapshotCreator::FunctionCodeHandling) [out/Release/node_mksnapshot]
4: 0x55cddae6f680 node::SnapshotBuilder::Generate(node::SnapshotData*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >) [out/Release/node_mksnapshot]
5: 0x55cddae707f4 node::SnapshotBuilder::Generate(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >) [out/Release/node_mksnapshot]
6: 0x55cddad822f2 BuildSnapshot(int, char**) [out/Release/node_mksnapshot]
7: 0x7f4802c9dfd0 [/lib/x86_64-linux-gnu/libc.so.6]
8: 0x7f4802c9e07d __libc_start_main [/lib/x86_64-linux-gnu/libc.so.6]
9: 0x55cdda8c9e05 _start [out/Release/node_mksnapshot]
Trace/breakpoint trap (core dumped)
ninja: build stopped: subcommand failed.
make: *** [Makefile:127: node] Error 1
Member
|
So long as there are no observable differences to the actual streams API, this is great. I would be concerned about possible performance impact but this code already has performance issues and this is not likely to be the primary bottleneck. |
Signed-off-by: Bryan English <[email protected]>
Signed-off-by: Bryan English <[email protected]>
Signed-off-by: Bryan English <[email protected]>
9e62322 to
f1d80b1
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #42822 +/- ##
==========================================
- Coverage 89.65% 89.64% -0.02%
==========================================
Files 708 708
Lines 220402 220441 +39
Branches 42269 42289 +20
==========================================
+ Hits 197597 197604 +7
- Misses 14671 14673 +2
- Partials 8134 8164 +30
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a
stream.web.donediagnostics channel to Web Streams. with the intention of having a straightforward way to detect when aReadableStreamhas been read to completion, without triggering the reading of the stream.This is useful for instrumentation tools trying to measure the length of a request/response cycle triggered by a
fetch().Why draft?
Right now I'm only testing directly calling
read()and async iterators.pipeThrough(),pipeTo(), and cancellation all need to be tested (and perhaps implemented).Also, the naming is certainly open for suggestions. I based the name of the channel on the only other prior art in Node.js core.
Finally, I had a weird thing happen with
mksnapshot, so I'm wondering if anyone knows how to better work around that. See the inline comment below.All that being said, I thought it was worth opening it now anyway, to make sure the approach is sound and agreeable.