You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Deprecation of readerFromStreamReader seems to have no direct replacement from Readable to Reader #4336
I'm unable to find a replacement for the deprecated readerFromStreamReader when trying to map a steams API Readable to a stdlib Reader
Steps to Reproduce
// old codeconstfileReader=(awaitDeno.open(tarballPath,{read: true})).readable.pipeThrough(newDecompressionStream('gzip')).getReader();constuntar=newUntar(readerFromStreamReader(fileReader));// trying to get this to workconstfileReader=(awaitDeno.open(tarballPath,{read: true})).readable.pipeThrough(newDecompressionStream('gzip')).getReader();constuntar=newUntar(fileReader);// is not compatible ^^^^^^^^^^ getReader.read() vs Reader.read(uint)
Expected behavior
I should be able to go from an Deno.FsFile while using a pipeThrough to a Reader in order to use some of the stdlib APIs like tar, etc.
If there is a way to convert this without writing custom code, this should be documented. Otherwise we should re-consider deprecating readerFromStreamReader.
However, this actually makes me wonder why the Deno.Reader and stdlib Reader interfaces do not conform to the Streams API ReadableStreamDefaultReader interface instead? I'm sure there is probably a good reason for this, but as an outsider this seems a bit backwards to me.
However, this actually makes me wonder why the Deno.Reader and stdlib Reader interfaces do not conform to the Streams API ReadableStreamDefaultReader interface instead? I'm sure there is probably a good reason for this, but as an outsider this seems a bit backwards to me.
I was a bit puzzled by the deviation of Deno.Reader and the stdlib Reader interfaces from the Streams API ReadableStreamDefaultReader myself. After digging around a bit, it seems they were directly inspired by Go's IO and streaming APIs, including their synchronous versions. This Go-inspiration is also very apparent in stdlib modules like BufReader, which even has a shoutout to Go in its JSDoc comments.
As Deno 2.0 shifts towards web streams, it appears it will phase out Go-style buffers, suggesting a move away from utilities like readerFromStreamReader. However, the plan for synchronous APIs like ReaderSync and WriterSync is less clear. The deprecations hint at their complete removal, which could disrupt modules relying synchronous ops that have been a staple in the Deno ecosystem for many years. A relevant example is Deno.stdout.writeSync(), which many projects and modules rely upon (see wait by denosaurs).
Given no direct Web Streams equivalents, this raises questions about the migration path for these synchronous methods. It's unclear why a hybrid model allowing both ReadableStream / WritableStream and synchronous APIs can't be considered, similar to the approach that's being used now in Deno.FsFile.
If there's a misunderstanding on my part regarding the documentation or the migration strategy, please let me know. I'm eager to continue to stay up to date with Deno as it grows and evolves.
Interesting. I know a Deno started in go and has been influenced by go to varying degrees. I think most of the parts that show through in this regard are the good parts. It does still seem a bit odd that given the push to use JS web standards like the Streams API (a good thing imo), the underlying Deno primitives differ and don't seem to be compatible (e.g. Deno.Reader/Writer, stdlib Reader/Writer).
As an end user of this, I don't feel like I should need to reach for a conversion function to adapt one to the other. I haven't tried going from Reader/Writer back to the Streams API, but don't recall seeing an inverse function from readerFromStreamReader at all in stdlib. Maybe not required?
We once planned to deprecate and remove the entire Reader / Writer interfaces at some point in favor of Web Streams, but recently we think that the plan is not feasible regarding the ecosystem impact.
Web Streams based APIs are still recommended way to perform most of I/O operations in Deno, but we don't remove existing read / write methods in Deno runtime, and utilities (including types, helper functions, etc) for them will be kept in std/io.
We once planned to deprecate and remove the entire Reader / Writer interfaces at some point in favor of Web Streams, but recently we think that the plan is not feasible regarding the ecosystem impact.
Given the lead up and evolution of the io based APIs & Streams API it makes sense not to rock the boat to much. Honestly, some of the deprecations around io & streams have been a bit of a pain to both figure out migration paths and to find non trivial conversion examples.
Web Streams based APIs are still recommended way to perform most of I/O operations in Deno, but we don't remove existing read / write methods in Deno runtime, and utilities (including types, helper functions, etc) for them will be kept in std/io
Agree. It seems required for some cases like the one raised in this issue. It would be nice if one didn't have to think about and/or know how to convert from one to another.
I wonder how feasible it would be to have stdlib functions could be extended to also accept both the Reader/Writer & ReadableStream/WriteableStream and then do the conversion internally?
I wonder how feasible it would be to have stdlib functions could be extended to also accept both the Reader/Writer & ReadableStream/WriteableStream and then do the conversion internally?
It's simpler to troubleshoot and use the corresponding function for a given type.
Activity
iuioiua commentedon Feb 16, 2024
This is a valid use case for un-deprecating
readerFromStreamReader(). See #4343.andrewthauer commentedon Feb 17, 2024
@iuioiua - Thanks for looking at this.
However, this actually makes me wonder why the
Deno.Readerand stdlibReaderinterfaces do not conform to the Streams APIReadableStreamDefaultReaderinterface instead? I'm sure there is probably a good reason for this, but as an outsider this seems a bit backwards to me.nberlette commentedon Feb 17, 2024
@andrewthauer
I was a bit puzzled by the deviation of
Deno.Readerand the stdlibReaderinterfaces from the Streams APIReadableStreamDefaultReadermyself. After digging around a bit, it seems they were directly inspired by Go's IO and streaming APIs, including their synchronous versions. This Go-inspiration is also very apparent in stdlib modules likeBufReader, which even has a shoutout to Go in its JSDoc comments.As Deno 2.0 shifts towards web streams, it appears it will phase out Go-style buffers, suggesting a move away from utilities like
readerFromStreamReader. However, the plan for synchronous APIs likeReaderSyncandWriterSyncis less clear. The deprecations hint at their complete removal, which could disrupt modules relying synchronous ops that have been a staple in the Deno ecosystem for many years. A relevant example isDeno.stdout.writeSync(), which many projects and modules rely upon (seewaitby denosaurs).Given no direct Web Streams equivalents, this raises questions about the migration path for these synchronous methods. It's unclear why a hybrid model allowing both
ReadableStream/WritableStreamand synchronous APIs can't be considered, similar to the approach that's being used now inDeno.FsFile.If there's a misunderstanding on my part regarding the documentation or the migration strategy, please let me know. I'm eager to continue to stay up to date with Deno as it grows and evolves.
Thanks,
Nick
andrewthauer commentedon Feb 17, 2024
Interesting. I know a Deno started in go and has been influenced by go to varying degrees. I think most of the parts that show through in this regard are the good parts. It does still seem a bit odd that given the push to use JS web standards like the Streams API (a good thing imo), the underlying Deno primitives differ and don't seem to be compatible (e.g. Deno.Reader/Writer, stdlib Reader/Writer).
As an end user of this, I don't feel like I should need to reach for a conversion function to adapt one to the other. I haven't tried going from Reader/Writer back to the Streams API, but don't recall seeing an inverse function from
readerFromStreamReaderat all in stdlib. Maybe not required?kt3k commentedon Feb 18, 2024
We once planned to deprecate and remove the entire Reader / Writer interfaces at some point in favor of Web Streams, but recently we think that the plan is not feasible regarding the ecosystem impact.
Web Streams based APIs are still recommended way to perform most of I/O operations in Deno, but we don't remove existing read / write methods in Deno runtime, and utilities (including types, helper functions, etc) for them will be kept in
std/io.andrewthauer commentedon Feb 18, 2024
Thanks for the explanation @kt3k!
Given the lead up and evolution of the
iobased APIs & Streams API it makes sense not to rock the boat to much. Honestly, some of the deprecations around io & streams have been a bit of a pain to both figure out migration paths and to find non trivial conversion examples.Agree. It seems required for some cases like the one raised in this issue. It would be nice if one didn't have to think about and/or know how to convert from one to another.
I wonder how feasible it would be to have stdlib functions could be extended to also accept both the
Reader/Writer&ReadableStream/WriteableStreamand then do the conversion internally?iuioiua commentedon Feb 18, 2024
It's simpler to troubleshoot and use the corresponding function for a given type.