This repository was archived by the owner on Jun 27, 2023. It is now read-only.
The context in CtxReadFull
is not propagated to the child nodes being read
#14
Labels
kind/bug
A bug in existing code (including security flaws)
The context used during read operations is always passed to the child PB node and "bifurcated" with a
context.WithCancel(ctx)
call,go-unixfs/io/pbdagreader.go
Lines 50 to 58 in 76afbe2
I understand that the rationale behind this is that if I cancel a context at a certain depth in the DAG I'm reading, that is, if I cancel a fetch operation of a node (promise) in the DAG, it will cancel all the operations below that depth that are happening in their children.
That context being "bifurcated" always comes from the internal
PBDagReader
's context:go-unixfs/io/pbdagreader.go
Lines 128 to 139 in 76afbe2
If we're doing a
Read
call (that callsCtxReadFull
with the internal context) the behavior is consistent with the rationale described above, but if the user manually callsCtxReadFull
with a custom context it will be applied only to the fetch operations (precalcNextBuf
) of the root node but it won't be used for the child nodes at deeper depths,go-unixfs/io/pbdagreader.go
Lines 169 to 176 in 76afbe2
The result is that a cancel of the custom context used in
CtxReadFull
won't cancel fetch operations (promises) at deeper levels, is that the intended behavior?The text was updated successfully, but these errors were encountered: