ipfs / ipfs/ipfs-webui

Switch text preview to range reads

Open
#1,652 1 comment 1 reaction 0 assignees View on GitHub
area/screen/files effort/hours exp/expert kind/bug need/analysis P2
Dominant language
JavaScript
Stars
1.6k
Forks
534
PR merge metrics
No merged PRs in 30d

Description

Alex noted how partial reads done during preview of text files may lead to leaking resources https://github.com/ipfs-shipyard/ipfs-webui/pull/1646#issuecomment-699043284

The whole point here is that we want to avoid unnecessary reads because text files such as logs can be pretty big.
Draining the iterator until completion when a text file is tens/hundreds of megabytes may not be the best approach to ensure resource cleanup happens.

Perhaps could leverage the fact that `ipfs.files.read|cat` support range requests via `offset` and `length` parameters?

The idea is that if the preview ask for specific byte range (256KB block), it no longer needs low level handling of iterator. Something like ` await concat(await read({ offset: n, length: 262144 }))` will read 256K block and without leaking any resources.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.