Skip to content

File.openRead does not respect back-pressure #60095

@mraleph

Description

@mraleph

File.openRead returns _FileStream which does not pause reading even if subscription to the stream is paused. See

_controller = new StreamController<Uint8List>(
sync: true,
onListen: _start,
onResume: _readBlock,
onCancel: () {
_unsubscribed = true;
return _closeFile();
},
);
return _controller.stream.listen(
onData,
onError: onError,
onDone: onDone,
cancelOnError: cancelOnError,
);

This means it does not respect the back-pressure. Consider the situation when you are piping a huge file into the socket (e.g. file.openRead().pipe(socket)) - the whole file will end up being buffered in memory because even though socket will pause once send buffer is full _FileStream will continue reading.

cc @brianquinlan

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.library-io

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions