fix(bag): stop infinite Range re-fetch loop when loading remote .bag files - #46
Merged
Merged
Conversation
…files @foxglove/rosbag's Filelike.size() must be synchronous (number), but the remote adapter in bag.worker.ts exposed an async/BigInt size(), which turned the library's un-awaited `size() - offset` arithmetic into NaN. A NaN-bounded read() can never be marked satisfied by CachedFilelike, so it kept re-deriving and re-fetching the same ~50MiB block forever while Bag.open() never resolved — reproduced end-to-end against a real 480MB bag file (initialize() hung past 12s and even emitted a literal `Range: bytes=NaN-NaN` request before the fix; resolves in ~500ms after). Also hardens CachedFilelike against this whole class of bug: reject non-finite/negative offsets and lengths at the read()/prefetch() entry points instead of silently enqueueing unsatisfiable requests, and bound the connection-error retry count so a persistently (but not rapidly) failing fetch can no longer retry forever. Bump to v1.7.9.
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.
Summary
.bagloading called@foxglove/rosbag'sFilelike.size()synchronously internally (this._file.size() - fileOffset, never awaited), butbag.worker.ts's remote adapter exposed anasync/BigIntsize(). The un-awaited subtraction silently becameNaN, whichCachedFilelikecan never mark as satisfied — it kept re-deriving and re-fetching the same ~50MiB block forever whileBag.open()never resolved.size(), matching the library's realFilelikecontract; import that type directly (dropping an unsafeascast) so a future mismatch is a compile error again.CachedFilelike: reject non-finite/negative offsets and lengths at theread()/prefetch()entry points instead of silently enqueueing unsatisfiable requests, and bound the connection-error retry count so a persistently (but not rapidly) failing fetch can no longer retry forever.Test plan
npm run lintnpm test(666 tests, incl. new regression coverage inCachedFilelike.test.tsandremoteBagReadable.test.ts)npx tsc -b --noEmitrgbd_dataset_freiburg1_xyz.bagserved locally over HTTP Range: before the fix,initialize()hung past 12s and emitted a literalRange: bytes=NaN-NaNrequest; after the fix it resolves in ~500ms with the correct topic list and no duplicate/invalid Range requests.