Skip to content

fix(datasets): close file handle on VideoDecoder init failure in cache - #3542

Merged
CarolinePascal merged 1 commit into
huggingface:mainfrom
jashshah999:fix/video-decoder-cache-leak
May 10, 2026
Merged

CarolinePascal merged 1 commit into
huggingface:mainfrom
jashshah999:fix/video-decoder-cache-leak

Conversation

@jashshah999

Copy link
Copy Markdown
Contributor

Summary

In VideoDecoderCache.get(), if VideoDecoder() raises during initialization (e.g., corrupted video file, unsupported codec), the fsspec file handle opened via __enter__() is never closed, causing a resource leak.

Added try/except to close the handle before re-raising.

Test plan

  • Normal path unchanged (decoder succeeds, handle stored in cache)
  • Exception path: handle is closed before propagating the error

If VideoDecoder() raises during initialization, the fsspec file handle
was leaked since it was opened via __enter__() but never closed on the
exception path. Now explicitly closes the handle before re-raising.
@github-actions github-actions Bot added the dataset Issues regarding data inputs, processing, or datasets label May 9, 2026

@CarolinePascal CarolinePascal left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thank you !

@CarolinePascal
CarolinePascal merged commit 9e83510 into huggingface:main May 10, 2026
9 checks passed
jogarulfo pushed a commit to spectrobot-project/spectrobot that referenced this pull request May 12, 2026
huggingface#3542)

If VideoDecoder() raises during initialization, the fsspec file handle
was leaked since it was opened via __enter__() but never closed on the
exception path. Now explicitly closes the handle before re-raising.
DannyHan-1124 pushed a commit to DannyHan-1124/lerobot that referenced this pull request May 26, 2026
huggingface#3542)

If VideoDecoder() raises during initialization, the fsspec file handle
was leaked since it was opened via __enter__() but never closed on the
exception path. Now explicitly closes the handle before re-raising.
jogarulfo pushed a commit to spectrobot-project/spectrobot that referenced this pull request Jun 4, 2026
huggingface#3542)

If VideoDecoder() raises during initialization, the fsspec file handle
was leaked since it was opened via __enter__() but never closed on the
exception path. Now explicitly closes the handle before re-raising.
jogarulfo pushed a commit to spectrobot-project/spectrobot that referenced this pull request Jun 4, 2026
huggingface#3542)

If VideoDecoder() raises during initialization, the fsspec file handle
was leaked since it was opened via __enter__() but never closed on the
exception path. Now explicitly closes the handle before re-raising.
jogarulfo pushed a commit to spectrobot-project/spectrobot that referenced this pull request Jun 4, 2026
huggingface#3542)

If VideoDecoder() raises during initialization, the fsspec file handle
was leaked since it was opened via __enter__() but never closed on the
exception path. Now explicitly closes the handle before re-raising.
jogarulfo pushed a commit to spectrobot-project/spectrobot that referenced this pull request Jun 10, 2026
huggingface#3542)

If VideoDecoder() raises during initialization, the fsspec file handle
was leaked since it was opened via __enter__() but never closed on the
exception path. Now explicitly closes the handle before re-raising.
jogarulfo pushed a commit to spectrobot-project/spectrobot that referenced this pull request Jun 10, 2026
huggingface#3542)

If VideoDecoder() raises during initialization, the fsspec file handle
was leaked since it was opened via __enter__() but never closed on the
exception path. Now explicitly closes the handle before re-raising.
wddler pushed a commit to wddler/lerobot that referenced this pull request Aug 4, 2026
huggingface#3542)

If VideoDecoder() raises during initialization, the fsspec file handle
was leaked since it was opened via __enter__() but never closed on the
exception path. Now explicitly closes the handle before re-raising.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dataset Issues regarding data inputs, processing, or datasets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants